ソースを参照

Remove `User.ensure_connected` checks

The underlying MQTT/HTTP calls will raise exceptions and this method
duplicates the timeout handling, which is currently mismatched with
recent MQTT changes.
Nick Barrett 2 年 前
コミット
17caf72095
2 ファイル変更0 行追加15 行削除
  1. 0 3
      mautrix_instagram/portal.py
  2. 0 12
      mautrix_instagram/user.py

+ 0 - 3
mautrix_instagram/portal.py

@@ -556,7 +556,6 @@ class Portal(DBPortal, BasePortal):
     ) -> None:
         sender, is_relay = await self.get_relay_sender(orig_sender, f"message {event_id}")
         assert sender, "user is not logged in"
-        await sender.ensure_connected()
 
         if is_relay:
             await self.apply_relay_message_format(orig_sender, message)
@@ -753,8 +752,6 @@ class Portal(DBPortal, BasePortal):
             await self._send_bridge_success(sender, redaction_event_id, EventType.ROOM_REDACTION)
 
     async def _handle_matrix_redaction(self, sender: u.User, event_id: EventID) -> None:
-        await sender.ensure_connected()
-
         reaction = await DBReaction.get_by_mxid(event_id, self.mxid)
         if reaction:
             try:

+ 0 - 12
mautrix_instagram/user.py

@@ -233,18 +233,6 @@ class User(DBUser, BaseUser):
     def is_connected(self) -> bool:
         return bool(self.client) and bool(self.mqtt) and self._is_connected
 
-    async def ensure_connected(self, max_wait_seconds: int = 5) -> None:
-        sleep_interval = 0.1
-        max_attempts = max_wait_seconds / sleep_interval
-        attempts = 0
-        while True:
-            if self.is_connected:
-                return
-            attempts += 1
-            if attempts > max_attempts:
-                raise Exception("You're not connected to instagram")
-            await asyncio.sleep(sleep_interval)
-
     async def connect(self, user: CurrentUser | None = None) -> None:
         if not self.state:
             await self.push_bridge_state(