Abandon fetching offline presence on 400 error
It seems like some servers return a M_UNRECOGNIZED code instead of M_FORBIDDEN or "offline" when trying to fetch the presence for a user and it's not available. Fixes https://github.com/mirukana/mirage/issues/116
This commit is contained in:
parent
a9c316fcf5
commit
32679aa7f8
|
@ -33,6 +33,12 @@ class MatrixError(Exception):
|
|||
return cls(response.transport_response.status, response.status_code)
|
||||
|
||||
|
||||
@dataclass
|
||||
class MatrixUnrecognized(MatrixError):
|
||||
http_code: int = 400
|
||||
m_code: str = "M_UNRECOGNIZED"
|
||||
|
||||
|
||||
@dataclass
|
||||
class MatrixInvalidAccessToken(MatrixError):
|
||||
http_code: int = 401
|
||||
|
|
|
@ -37,7 +37,7 @@ from . import __app_name__, __display_name__, utils
|
|||
from .errors import (
|
||||
BadMimeType, InvalidUserId, InvalidUserInContext, MatrixBadGateway,
|
||||
MatrixError, MatrixForbidden, MatrixInvalidAccessToken, MatrixNotFound,
|
||||
MatrixTooLarge, MatrixUnauthorized, UneededThumbnail,
|
||||
MatrixTooLarge, MatrixUnauthorized, MatrixUnrecognized, UneededThumbnail,
|
||||
UserFromOtherServerDisallowed,
|
||||
)
|
||||
from .html_markdown import HTML_PROCESSOR as HTML
|
||||
|
@ -1474,7 +1474,7 @@ class MatrixClient(nio.AsyncClient):
|
|||
try:
|
||||
async with self.backend.concurrent_get_presence_limit:
|
||||
resp = await self.get_presence(user_id)
|
||||
except MatrixForbidden:
|
||||
except (MatrixForbidden, MatrixUnrecognized):
|
||||
return
|
||||
|
||||
await self.nio_callbacks.onPresenceEvent(nio.PresenceEvent(
|
||||
|
|
Loading…
Reference in New Issue
Block a user