fix: prevent insert_shared_chat_by_chat_id crash when chat is None (#20273)

Add null check after db.get(Chat, chat_id) before accessing chat.share_id. Returns None instead of crashing with AttributeError when chat doesn't exist.
This commit is contained in:
Classic298
2025-12-31 17:38:57 +04:00
committed by GitHub
parent b91e8b73ab
commit 048692c068
+3
View File
@@ -488,6 +488,9 @@ class ChatTable:
with get_db_context(db) as db:
# Get the existing chat to share
chat = db.get(Chat, chat_id)
# Check if chat exists
if not chat:
return None
# Check if the chat is already shared
if chat.share_id:
return self.get_chat_by_id_and_user_id(chat.share_id, "shared", db=db)