diff options
author | Travis Ralston <travpc@gmail.com> | 2018-11-22 08:47:35 -0700 |
---|---|---|
committer | Brendan Abolivier <babolivier@matrix.org> | 2019-02-13 15:16:04 +0000 |
commit | 0463d9ba75914e869d8a1f0fc17a306d43d04a34 (patch) | |
tree | 1e999cea766035e96bfc5e9478ad7352cacdfb1e | |
parent | Preserve log contexts in the room_member_handler (diff) | |
download | synapse-0463d9ba75914e869d8a1f0fc17a306d43d04a34.tar.xz |
Safer execution
-rw-r--r-- | synapse/handlers/federation.py | 3 | ||||
-rw-r--r-- | synapse/handlers/room_member.py | 24 |
2 files changed, 16 insertions, 11 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 187ad57033..e189989408 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -110,6 +110,7 @@ class FederationHandler(BaseHandler): self.hs = hs + self.clock = hs.get_clock() self.store = hs.get_datastore() # type: synapse.storage.DataStore self.federation_client = hs.get_federation_client() self.federation_sender = hs.get_federation_sender() @@ -1435,7 +1436,7 @@ class FederationHandler(BaseHandler): except Exception: # We're going to retry, but we should log the error logger.exception("Error auto-accepting invite on attempt %d" % attempt) - yield self.hs.get_clock().sleep(1) + yield self.clock.sleep(1) if not joined: logger.error("Giving up on trying to auto-accept invite: too many attempts") diff --git a/synapse/handlers/room_member.py b/synapse/handlers/room_member.py index 18342fb675..147f8e1789 100644 --- a/synapse/handlers/room_member.py +++ b/synapse/handlers/room_member.py @@ -455,10 +455,11 @@ class RoomMemberHandler(object): prev_events_and_hashes=prev_events_and_hashes, content=content, ) - logcontext.run_in_background( - self._send_merged_user_invites, - requester, room_id, - ) + if effective_membership_state == Membership.JOIN: + logcontext.run_in_background( + self._send_merged_user_invites, + requester, room_id, + ) defer.returnValue(res) @defer.inlineCallbacks @@ -479,12 +480,15 @@ class RoomMemberHandler(object): if self.hs.is_mine(child) or child_id == requester.user.to_string(): # TODO: Handle auto-invite for local users (not a priority) continue - self.update_membership( - requester=requester, - target=child, - room_id=room_id, - action="invite", - ) + 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)) @defer.inlineCallbacks def send_membership_event( |