mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-10-21 05:05:36 +00:00
Disconnect now drops only the key or sign-in: the plugin stays in Yours with its tool settings, its tools are not offered, and Connect brings it back with a sign-in, a key, or nothing to enter. Remove is the old disconnect and deletes the plugin. The disconnected state is a new column folded into the unreleased migration 0028. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
683 B
Python
22 lines
683 B
Python
"""Disconnecting a plugin: its sign-in goes, the row and the user's tool settings stay.
|
|
|
|
`credential_kind` stays too, so the screen knows whether connecting again needs a key,
|
|
an account sign-in, or nothing.
|
|
"""
|
|
|
|
from datetime import UTC, datetime
|
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
from modules.plugins.installed.models import InstalledPlugin
|
|
|
|
|
|
def disconnect(session: Session, plugin_id: str) -> InstalledPlugin | None:
|
|
"""None when no such plugin is connected."""
|
|
plugin = session.get(InstalledPlugin, plugin_id)
|
|
if plugin is None:
|
|
return None
|
|
plugin.credential = None
|
|
plugin.disconnected_at = datetime.now(UTC)
|
|
session.flush()
|
|
return plugin
|