fix/refac: shared chat files behaviour

This commit is contained in:
Timothy Jaeryang Baek
2025-12-21 23:29:54 +04:00
parent bd7f1869ce
commit 45e3237756
2 changed files with 21 additions and 1 deletions
+12
View File
@@ -1337,5 +1337,17 @@ class ChatTable:
except Exception:
return False
def get_shared_chats_by_file_id(self, file_id: str) -> list[ChatModel]:
with get_db() as db:
# Join Chat and ChatFile tables to get shared chats associated with the file_id
all_chats = (
db.query(Chat)
.join(ChatFile, Chat.id == ChatFile.chat_id)
.filter(ChatFile.file_id == file_id, Chat.share_id.isnot(None))
.all()
)
return [ChatModel.model_validate(chat) for chat in all_chats]
Chats = ChatTable()