Bläddra i källkod

Add config option to disable initial backfill after creating portals

Tulir Asokan 2 år sedan
förälder
incheckning
adf45cb399

+ 1 - 0
mautrix_instagram/config.py

@@ -60,6 +60,7 @@ class Config(BaseBridgeConfig):
         copy("bridge.double_puppet_allow_discovery")
         copy("bridge.login_shared_secret_map")
         copy("bridge.federate_rooms")
+        copy("bridge.backfill.enable_initial")
         copy("bridge.backfill.enable")
         copy("bridge.backfill.msc2716")
         copy("bridge.backfill.double_puppet_backfill")

+ 4 - 9
mautrix_instagram/example-config.yaml

@@ -138,15 +138,10 @@ bridge:
     federate_rooms: true
     # Settings for backfilling messages from Instagram.
     backfill:
-        # Whether to enable backfilling at all.
-        #
-        # This requires a server with MSC2716 support, which is currently an
-        # experimental feature in synapse. It can be enabled by setting
-        # experimental_features -> msc2716_enabled to true in homeserver.yaml.
-        #
-        # Note that prior to Synapse 1.49, there were some bugs with the
-        # implementation, especially if using event persistence workers. There
-        # are also still some issues in Synapse's federation implementation.
+        # Enable initial backfill (~10 messages after creating portal)?
+        enable_initial: true
+        # Enable backfill queue? This is used for backfilling additional threads after the initial sync,
+        # and when MSC2716 is enabled, to backfill message history going backwards.
         enable: false
         # Use MSC2716 for backfilling? If this is disabled, backfilling only happens when syncing threads,
         # and the incremental settings below don't apply.

+ 2 - 3
mautrix_instagram/portal.py

@@ -1485,9 +1485,8 @@ class Portal(DBPortal, BasePortal):
                 # Failed to create
                 return
 
-            if self.config["bridge.backfill.enable"]:
-                if self.config["bridge.backfill.msc2716"]:
-                    await self.enqueue_immediate_backfill(source, 0)
+            if self.config["bridge.backfill.enable"] and self.config["bridge.backfill.msc2716"]:
+                await self.enqueue_immediate_backfill(source, 0)
 
         intent = sender.intent_for(self)
         asyncio.create_task(intent.set_typing(self.mxid, timeout=0))

+ 3 - 0
mautrix_instagram/user.py

@@ -551,6 +551,9 @@ class User(DBUser, BaseUser):
         else:
             await portal.update_matrix_room(self, thread)
 
+        if not self.config["bridge.backfill.enable_initial"]:
+            return True
+
         last_message = await DBMessage.get_last(portal.mxid)
         cursor = thread.oldest_cursor
         if last_message: