diff options
author | Erik Johnston <erik@matrix.org> | 2018-11-29 11:32:03 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2018-11-29 11:32:03 +0000 |
commit | cf09912280bc83209a1bd02296834ca08784004d (patch) | |
tree | 593d38e84d49dc6593406861f8b47047913c4a56 /synapse | |
parent | Merge pull request #4235 from matrix-org/travis/fix-auto-invite-errors (diff) | |
download | synapse-cf09912280bc83209a1bd02296834ca08784004d.tar.xz |
Don't log ERROR when no profile exists
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/handlers/federation.py | 3 | ||||
-rw-r--r-- | synapse/handlers/room_member.py | 68 |
2 files changed, 42 insertions, 29 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 9848534120..d0296a7bf6 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -55,7 +55,7 @@ from synapse.replication.http.federation import ( ) from synapse.replication.http.membership import ReplicationUserJoinedLeftRoomRestServlet from synapse.state import StateResolutionStore, resolve_events_with_store -from synapse.types import UserID, get_domain_from_id, create_requester +from synapse.types import UserID, create_requester, get_domain_from_id from synapse.util import logcontext, unwrapFirstError from synapse.util.async_helpers import Linearizer from synapse.util.distributor import user_joined_room @@ -1333,7 +1333,6 @@ class FederationHandler(BaseHandler): if not joined: logger.error("Giving up on trying to auto-accept invite: too many attempts") - @defer.inlineCallbacks def do_remotely_reject_invite(self, target_hosts, room_id, user_id): origin, event = yield self._make_and_verify_event( diff --git a/synapse/handlers/room_member.py b/synapse/handlers/room_member.py index f463bb3349..4bf48a507d 100644 --- a/synapse/handlers/room_member.py +++ b/synapse/handlers/room_member.py @@ -28,8 +28,8 @@ from twisted.internet import defer import synapse.server import synapse.types from synapse.api.constants import EventTypes, Membership -from synapse.api.errors import AuthError, Codes, SynapseError -from synapse.types import RoomID, UserID, RoomAlias +from synapse.api.errors import AuthError, Codes, NotFoundError, SynapseError +from synapse.types import RoomAlias, RoomID, UserID from synapse.util import logcontext from synapse.util.async_helpers import Linearizer from synapse.util.distributor import user_joined_room, user_left_room @@ -465,33 +465,47 @@ class RoomMemberHandler(object): @defer.inlineCallbacks def _send_merged_user_invites(self, requester, room_id): try: - profile_alias = "#_profile_" + requester.user.localpart + ":" + self.hs.hostname + profile_alias = "#_profile_%s:%s" % ( + requester.user.localpart, self.hs.hostname, + ) profile_alias = RoomAlias.from_string(profile_alias) - profile_room_id, remote_room_hosts = yield self.lookup_room_alias(profile_alias) - if profile_room_id: - linked_accounts = yield self.state_handler.get_current_state( - room_id=profile_room_id.to_string(), - event_type="m.linked_accounts", - state_key="", + try: + profile_room_id, remote_room_hosts = yield self.lookup_room_alias( + profile_alias, + ) + except NotFoundError: + logger.info( + "Not sending merged invites as %s does not exists", + profile_alias ) - if not linked_accounts or not linked_accounts.content['all_children']: - return - for child_id in linked_accounts.content['all_children']: - child = UserID.from_string(child_id) - if self.hs.is_mine(child) or child_id == requester.user.to_string(): - # TODO: Handle auto-invite for local users (not a priority) - continue - try: - yield self.update_membership( - requester=requester, - target=child, - room_id=room_id, - action="invite", - ) - except Exception: - logger.exception("Failed to invite %s to %s" % (child_id, room_id)) + return + + linked_accounts = yield self.state_handler.get_current_state( + room_id=profile_room_id.to_string(), + event_type="m.linked_accounts", + state_key="", + ) + if not linked_accounts or not linked_accounts.content['all_children']: + return + for child_id in linked_accounts.content['all_children']: + child = UserID.from_string(child_id) + if self.hs.is_mine(child) or child_id == requester.user.to_string(): + # TODO: Handle auto-invite for local users (not a priority) + continue + try: + yield self.update_membership( + requester=requester, + target=child, + room_id=room_id, + action="invite", + ) + except Exception: + logger.exception("Failed to invite %s to %s", child_id, room_id) except Exception: - logger.exception("Failed to send invites to children of %s in %s" % (requester.user.to_string(), room_id)) + logger.exception( + "Failed to send invites to children of %s in %s", + requester.user.to_string(), room_id, + ) @defer.inlineCallbacks def send_membership_event( @@ -619,7 +633,7 @@ class RoomMemberHandler(object): mapping = yield directory_handler.get_association(room_alias) if not mapping: - raise SynapseError(404, "No such room alias") + raise NotFoundError("No such room alias") room_id = mapping["room_id"] servers = mapping["servers"] |