Skip to content

Commit

Permalink
catch UnregisteredUserError in _update_participants
Browse files Browse the repository at this point in the history
  • Loading branch information
maltee1 committed Jun 11, 2022
1 parent 18f22bf commit bfd6e7d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions mausignald/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class UnregisteredUserError(ResponseError):
pass


class ProfileUnavailableError(ResponseError):
pass


response_error_types = {
"invalid_request": RequestValidationFailure,
"TimeoutException": TimeoutException,
Expand All @@ -119,6 +123,7 @@ class UnregisteredUserError(ResponseError):
"ScanTimeoutError": ScanTimeoutError,
"OwnProfileKeyDoesNotExistError": OwnProfileKeyDoesNotExistError,
"UnregisteredUserError": UnregisteredUserError,
"ProfileUnavailableError": ProfileUnavailableError,
# TODO add rest from https://gitlab.com/signald/signald/-/tree/main/src/main/java/io/finn/signald/clientprotocol/v1/exceptions
}

Expand Down
17 changes: 14 additions & 3 deletions mautrix_signal/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
import pathlib
import time

from mausignald.errors import AttachmentTooLargeError, NotConnected, RPCError
from mausignald.errors import (
AttachmentTooLargeError,
NotConnected,
ProfileUnavailableError,
RPCError,
)
from mausignald.types import (
AccessControlMode,
Address,
Expand Down Expand Up @@ -1649,7 +1654,10 @@ async def _update_participants(self, source: u.User, info: ChatInfo) -> None:
await self.main_intent.invite_user(self.mxid, user.mxid, check_cache=True)

puppet = await p.Puppet.get_by_address(address)
await source.sync_contact(address)
try:
await source.sync_contact(address)
except ProfileUnavailableError:
self.log.debug(f"Profile of puppet with {address} is unavailable")
await puppet.intent_for(self).ensure_joined(self.mxid)
remove_users.discard(puppet.default_mxid)

Expand All @@ -1660,7 +1668,10 @@ async def _update_participants(self, source: u.User, info: ChatInfo) -> None:
await self.main_intent.invite_user(self.mxid, user.mxid, check_cache=True)

puppet = await p.Puppet.get_by_address(address)
await source.sync_contact(address)
try:
await source.sync_contact(address)
except ProfileUnavailableError:
self.log.debug(f"Profile of puppet with {address} is unavailable")
await self.main_intent.invite_user(
self.mxid, puppet.intent_for(self).mxid, check_cache=True
)
Expand Down

0 comments on commit bfd6e7d

Please sign in to comment.