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:
1 parent
b91e8b73ab
commit
048692c068
1 file changed
+3
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user