Jelajahi Sumber

Log checkpoint error content

Tulir Asokan 3 tahun lalu
induk
melakukan
4851923cbe

+ 1 - 0
mauigpapi/errors/__init__.py

@@ -5,6 +5,7 @@ from .response import (
     IGBad2FACodeError,
     IGChallengeError,
     IGChallengeWrongCodeError,
+    IGCheckpointError,
     IGConsentRequiredError,
     IGFBNoContactPointFoundError,
     IGInactiveUserError,

+ 4 - 0
mauigpapi/errors/response.py

@@ -81,6 +81,10 @@ class IGRateLimitError(IGResponseError):
     pass
 
 
+class IGCheckpointError(IGResponseError):
+    pass
+
+
 class IGChallengeError(IGResponseError):
     body: ChallengeResponse
 

+ 3 - 0
mauigpapi/http/base.py

@@ -31,6 +31,7 @@ from ..errors import (
     IGActionSpamError,
     IGBad2FACodeError,
     IGChallengeError,
+    IGCheckpointError,
     IGConsentRequiredError,
     IGFBNoContactPointFoundError,
     IGInactiveUserError,
@@ -207,6 +208,8 @@ class BaseAndroidAPI:
                 err = IGChallengeError(resp, data)
                 self.state.challenge_path = err.url
                 raise err
+            elif message == "checkpoint_required":
+                raise IGCheckpointError(resp, data)
             elif message == "consent_required":
                 raise IGConsentRequiredError(resp, data)
             elif message == "user_has_logged_out":

+ 6 - 1
mautrix_instagram/user.py

@@ -23,6 +23,7 @@ import time
 from mauigpapi import AndroidAPI, AndroidMQTT, AndroidState
 from mauigpapi.errors import (
     IGChallengeError,
+    IGCheckpointError,
     IGConsentRequiredError,
     IGNotLoggedInError,
     IGRateLimitError,
@@ -321,6 +322,8 @@ class User(DBUser, BaseUser):
             await self.sync()
         except Exception as e:
             self.log.exception("Exception while syncing")
+            if isinstance(e, IGCheckpointError):
+                self.log.debug("Checkpoint error content: %s", e.body)
             await self.push_bridge_state(
                 BridgeStateEvent.UNKNOWN_ERROR, info={"python_error": str(e)}
             )
@@ -351,6 +354,8 @@ class User(DBUser, BaseUser):
                         self.log.exception(
                             f"Error while syncing for refresh, retrying in {minutes} minute{s}"
                         )
+                        if isinstance(e, IGCheckpointError):
+                            self.log.debug("Checkpoint error content: %s", e.body)
                         await self.push_bridge_state(
                             BridgeStateEvent.UNKNOWN_ERROR,
                             error="unknown-error",
@@ -434,7 +439,7 @@ class User(DBUser, BaseUser):
                 )
                 await asyncio.sleep(sleep_minutes * 60)
                 sleep_minutes += 2
-            except IGChallengeError as e:
+            except (IGChallengeError, IGConsentRequiredError) as e:
                 await self._handle_checkpoint(e, on="sync")
                 return