Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch ProfileUnavailableError in _update_participants #270

Merged
merged 1 commit into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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