From a0d932b986a566355effb821d765d5aa087c533f Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 2 Apr 2024 08:00:26 -0700 Subject: [PATCH] fix: cascade shared chat delete --- backend/apps/web/models/chats.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/apps/web/models/chats.py b/backend/apps/web/models/chats.py index a57434dbe..e6c0aefa0 100644 --- a/backend/apps/web/models/chats.py +++ b/backend/apps/web/models/chats.py @@ -230,10 +230,13 @@ class ChatTable: def delete_chats_by_user_id(self, user_id: str) -> bool: try: + + self.delete_shared_chats_by_user_id(user_id) + query = Chat.delete().where(Chat.user_id == user_id) query.execute() # Remove the rows, return number of rows removed. - return True and self.delete_shared_chats_by_user_id(user_id) + return True except: return False @@ -244,6 +247,8 @@ class ChatTable: for chat in Chat.select().where(Chat.user_id == user_id) ] + print(shared_chat_ids) + query = Chat.delete().where(Chat.user_id << shared_chat_ids) query.execute() # Remove the rows, return number of rows removed.