From c0890759be4fe72bc6d137c4cf8c0c13d58d810f Mon Sep 17 00:00:00 2001 From: Malte E Date: Sat, 11 Jun 2022 10:28:26 +0200 Subject: [PATCH] catch ProfileUnavailableError in _update_participants --- mausignald/errors.py | 5 +++++ mautrix_signal/portal.py | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/mausignald/errors.py b/mausignald/errors.py index 0ac67df9..7661049d 100644 --- a/mausignald/errors.py +++ b/mausignald/errors.py @@ -106,6 +106,10 @@ class UnregisteredUserError(ResponseError): pass +class ProfileUnavailableError(ResponseError): + pass + + response_error_types = { "invalid_request": RequestValidationFailure, "TimeoutException": TimeoutException, @@ -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 } diff --git a/mautrix_signal/portal.py b/mautrix_signal/portal.py index 5935722c..4fa87a71 100644 --- a/mautrix_signal/portal.py +++ b/mautrix_signal/portal.py @@ -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, @@ -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) @@ -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 )