mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-16 06:14:12 +00:00
Drop the sharing settings of tools deleted with their connection
Removing a connection with its tools now also deletes those tools' sharing switches in the same transaction, as deleting a tool on its own does. Team grants and chat preferences were already removed with the tools.
This commit is contained in:
1 parent
a45e369d0f
commit
b2d26c72ed
2 files changed
+30
-1
No files matched your search
@@ -1442,8 +1442,15 @@ def remove_connection(conn, row: dict, *, sources: str = "keep", tools: str = "d
|
||||
except CredentialDecryptionError:
|
||||
pass
|
||||
if tools == "delete":
|
||||
# Team grants go with the tools (delete trigger) and chat preferences
|
||||
# by FK cascade; the owner's sharing switches have no FK.
|
||||
conn.execute(
|
||||
text("DELETE FROM user_tools WHERE connection_id = CAST(:id AS uuid) AND user_id = :user_id"),
|
||||
text(
|
||||
"WITH gone AS (DELETE FROM user_tools WHERE connection_id = CAST(:id AS uuid) "
|
||||
"AND user_id = :user_id RETURNING id) "
|
||||
"DELETE FROM resource_share_settings WHERE resource_type = 'tool' "
|
||||
"AND resource_id IN (SELECT id FROM gone)"
|
||||
),
|
||||
{"id": connection_id, "user_id": row["user_id"]},
|
||||
)
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user