Эх сурвалжийг харах

Drop unhandleable items in backfill

Tulir Asokan 3 жил өмнө
parent
commit
3e197f847e

+ 26 - 0
mauigpapi/types/thread_item.py

@@ -545,6 +545,32 @@ class ThreadItem(SerializableAttrs):
             log.debug("Failed to deserialize ThreadItem %s", data)
             return Obj(**data)
 
+    @property
+    def unhandleable_type(self) -> str:
+        if self.action_log:
+            return "action log"
+        return "unknown"
+
+    @property
+    def is_handleable(self) -> bool:
+        return bool(
+            self.media
+            or self.animated_media
+            or self.voice_media
+            or self.visual_media
+            or self.location
+            or self.profile
+            or self.reel_share
+            or self.media_share
+            or self.direct_media_share
+            or self.story_share
+            or self.clip
+            or self.felix_share
+            or self.text
+            or self.like
+            or self.link
+        )
+
 
 # This resolves the 'ThreadItem' string into an actual type.
 # Starting Python 3.10, all type annotations will be strings and have to be resolved like this.

+ 5 - 0
mautrix_instagram/portal.py

@@ -1449,6 +1449,11 @@ class Portal(DBPortal, BasePortal):
                         " that's already in the database."
                     )
                     break
+            elif not item.is_handleable:
+                self.log.debug(
+                    f"Dropping {item.unhandleable_type} item {item.item_id} in backfill"
+                )
+                continue
             items.append(item)
         return items