Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
10cad605
Commit
10cad605
authored
Apr 02, 2024
by
Timothy J. Baek
Browse files
feat: chat cascade delete
parent
c6296e51
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
backend/apps/web/models/chats.py
backend/apps/web/models/chats.py
+15
-1
No files found.
backend/apps/web/models/chats.py
View file @
10cad605
...
@@ -224,7 +224,7 @@ class ChatTable:
...
@@ -224,7 +224,7 @@ class ChatTable:
query
=
Chat
.
delete
().
where
((
Chat
.
id
==
id
)
&
(
Chat
.
user_id
==
user_id
))
query
=
Chat
.
delete
().
where
((
Chat
.
id
==
id
)
&
(
Chat
.
user_id
==
user_id
))
query
.
execute
()
# Remove the rows, return number of rows removed.
query
.
execute
()
# Remove the rows, return number of rows removed.
return
True
return
True
and
self
.
delete_shared_chat_by_chat_id
(
id
)
except
:
except
:
return
False
return
False
...
@@ -233,6 +233,20 @@ class ChatTable:
...
@@ -233,6 +233,20 @@ class ChatTable:
query
=
Chat
.
delete
().
where
(
Chat
.
user_id
==
user_id
)
query
=
Chat
.
delete
().
where
(
Chat
.
user_id
==
user_id
)
query
.
execute
()
# Remove the rows, return number of rows removed.
query
.
execute
()
# Remove the rows, return number of rows removed.
return
True
and
self
.
delete_shared_chats_by_user_id
(
user_id
)
except
:
return
False
def
delete_shared_chats_by_user_id
(
self
,
user_id
:
str
)
->
bool
:
try
:
shared_chat_ids
=
[
f
"shared-
{
chat
.
id
}
"
for
chat
in
Chat
.
select
().
where
(
Chat
.
user_id
==
user_id
)
]
query
=
Chat
.
delete
().
where
(
Chat
.
user_id
<<
shared_chat_ids
)
query
.
execute
()
# Remove the rows, return number of rows removed.
return
True
return
True
except
:
except
:
return
False
return
False
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment