Browse Source

Update proxy on refresh

By doing this we should restore balance between proxies.
Nick Barrett 2 years ago
parent
commit
76610af11e
2 changed files with 4 additions and 2 deletions
  1. 1 1
      mautrix_instagram/__main__.py
  2. 3 1
      mautrix_instagram/user.py

+ 1 - 1
mautrix_instagram/__main__.py

@@ -125,7 +125,7 @@ class InstagramBridge(Bridge):
                     continue
                 log.debug("Executing periodic reconnect for %s", user.mxid)
                 try:
-                    await user.refresh(resync=resync)
+                    await user.refresh(resync=resync, update_proxy=True)
                 except asyncio.CancelledError:
                     log.debug("Periodic reconnect loop stopped")
                     return

+ 3 - 1
mautrix_instagram/user.py

@@ -470,11 +470,13 @@ class User(DBUser, BaseUser):
             if portal.mxid
         }
 
-    async def refresh(self, resync: bool = True) -> None:
+    async def refresh(self, resync: bool = True, update_proxy: bool = False) -> None:
         self._is_refreshing = True
         try:
             await self.stop_listen()
             self.state.reset_pigeon_session_id()
+            if update_proxy and self.proxy_handler.update_proxy_url(reason="reconnect"):
+                await self.on_proxy_update()
             if resync:
                 retry_count = 0
                 minutes = 1