refac: share chat routes

This commit is contained in:
Timothy J. Baek 2024-04-02 07:04:29 -07:00
parent e4d101e550
commit 180dd3966b
2 changed files with 13 additions and 6 deletions

View file

@ -181,6 +181,13 @@ class ChatTable:
.order_by(Chat.timestamp.desc())
]
def get_chat_by_id(self, id: str) -> Optional[ChatModel]:
try:
chat = Chat.get(Chat.id == id)
return ChatModel(**model_to_dict(chat))
except:
return None
def get_chat_by_id_and_user_id(self, id: str, user_id: str) -> Optional[ChatModel]:
try:
chat = Chat.get(Chat.id == id, Chat.user_id == user_id)