瀏覽代碼

Fix portal to chat with self

Tulir Asokan 4 年之前
父節點
當前提交
6a80269760
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      mautrix_instagram/portal.py

+ 6 - 1
mautrix_instagram/portal.py

@@ -604,6 +604,8 @@ class Portal(DBPortal, BasePortal):
     # region Updating portal info
     # region Updating portal info
 
 
     async def update_info(self, thread: Thread, source: 'u.User') -> None:
     async def update_info(self, thread: Thread, source: 'u.User') -> None:
+        if self.is_direct and self.other_user_pk == source.igpk and not thread.thread_title:
+            thread.thread_title = "Instagram chat with yourself"
         changed = await self._update_name(thread.thread_title)
         changed = await self._update_name(thread.thread_title)
         if changed:
         if changed:
             await self.update_bridge_info()
             await self.update_bridge_info()
@@ -933,7 +935,10 @@ class Portal(DBPortal, BasePortal):
             receiver = 0
             receiver = 0
             other_user_pk = None
             other_user_pk = None
         else:
         else:
-            other_user_pk = thread.users[0].pk
+            if len(thread.users) == 0:
+                other_user_pk = receiver
+            else:
+                other_user_pk = thread.users[0].pk
         return await cls.get_by_thread_id(thread.thread_id, receiver, is_group=thread.is_group,
         return await cls.get_by_thread_id(thread.thread_id, receiver, is_group=thread.is_group,
                                           other_user_pk=other_user_pk)
                                           other_user_pk=other_user_pk)
     # endregion
     # endregion