浏览代码

Ignore thread sync events in DMs without existing portals

Tulir Asokan 3 年之前
父节点
当前提交
193758a81a
共有 1 个文件被更改,包括 15 次插入2 次删除
  1. 15 2
      mautrix_instagram/user.py

+ 15 - 2
mautrix_instagram/user.py

@@ -667,9 +667,22 @@ class User(DBUser, BaseUser):
 
     @async_time(METRIC_THREAD_SYNC)
     async def handle_thread_sync(self, evt: ThreadSyncEvent) -> None:
-        self.log.trace("Received thread sync event %s", evt)
+        self.log.trace("Thread sync event content: %s", evt)
         portal = await po.Portal.get_by_thread(evt, receiver=self.igpk)
-        await portal.create_matrix_room(self, evt)
+        if portal.mxid:
+            self.log.debug("Got thread sync event for %s with existing portal", portal.thread_id)
+            await portal.update_matrix_room(self, evt)
+        elif evt.is_group:
+            self.log.debug(
+                "Got thread sync event for group %s without existing portal, creating room",
+                portal.thread_id,
+            )
+            await portal.create_matrix_room(self, evt)
+        else:
+            self.log.debug(
+                "Got thread sync event for DM %s without existing portal, ignoring",
+                portal.thread_id,
+            )
 
     @async_time(METRIC_RTD)
     async def handle_rtd(self, evt: RealtimeDirectEvent) -> None: