mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-19 01:21:09 +03:00
Safer execution
This commit is contained in:
parent
b26d8cea66
commit
0463d9ba75
2 changed files with 16 additions and 11 deletions
|
@ -110,6 +110,7 @@ class FederationHandler(BaseHandler):
|
||||||
|
|
||||||
self.hs = hs
|
self.hs = hs
|
||||||
|
|
||||||
|
self.clock = hs.get_clock()
|
||||||
self.store = hs.get_datastore() # type: synapse.storage.DataStore
|
self.store = hs.get_datastore() # type: synapse.storage.DataStore
|
||||||
self.federation_client = hs.get_federation_client()
|
self.federation_client = hs.get_federation_client()
|
||||||
self.federation_sender = hs.get_federation_sender()
|
self.federation_sender = hs.get_federation_sender()
|
||||||
|
@ -1435,7 +1436,7 @@ class FederationHandler(BaseHandler):
|
||||||
except Exception:
|
except Exception:
|
||||||
# We're going to retry, but we should log the error
|
# We're going to retry, but we should log the error
|
||||||
logger.exception("Error auto-accepting invite on attempt %d" % attempt)
|
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:
|
if not joined:
|
||||||
logger.error("Giving up on trying to auto-accept invite: too many attempts")
|
logger.error("Giving up on trying to auto-accept invite: too many attempts")
|
||||||
|
|
||||||
|
|
|
@ -455,10 +455,11 @@ class RoomMemberHandler(object):
|
||||||
prev_events_and_hashes=prev_events_and_hashes,
|
prev_events_and_hashes=prev_events_and_hashes,
|
||||||
content=content,
|
content=content,
|
||||||
)
|
)
|
||||||
logcontext.run_in_background(
|
if effective_membership_state == Membership.JOIN:
|
||||||
self._send_merged_user_invites,
|
logcontext.run_in_background(
|
||||||
requester, room_id,
|
self._send_merged_user_invites,
|
||||||
)
|
requester, room_id,
|
||||||
|
)
|
||||||
defer.returnValue(res)
|
defer.returnValue(res)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
@ -479,12 +480,15 @@ class RoomMemberHandler(object):
|
||||||
if self.hs.is_mine(child) or child_id == requester.user.to_string():
|
if self.hs.is_mine(child) or child_id == requester.user.to_string():
|
||||||
# TODO: Handle auto-invite for local users (not a priority)
|
# TODO: Handle auto-invite for local users (not a priority)
|
||||||
continue
|
continue
|
||||||
self.update_membership(
|
try:
|
||||||
requester=requester,
|
yield self.update_membership(
|
||||||
target=child,
|
requester=requester,
|
||||||
room_id=room_id,
|
target=child,
|
||||||
action="invite",
|
room_id=room_id,
|
||||||
)
|
action="invite",
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Failed to invite %s to %s" % (child_id, room_id))
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def send_membership_event(
|
def send_membership_event(
|
||||||
|
|
Loading…
Reference in a new issue