diff options
author | Erik Johnston <erik@matrix.org> | 2018-03-01 10:18:33 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2018-03-01 10:18:37 +0000 |
commit | f381d6381344eb442f46ae27f29e039175721ff5 (patch) | |
tree | 1cccf81ea8935305ef6cac5da0e9677ebb832f42 /synapse/handlers | |
parent | Correctly send ratelimit and extra_users params (diff) | |
download | synapse-f381d6381344eb442f46ae27f29e039175721ff5.tar.xz |
Check event auth on the worker
Diffstat (limited to '')
-rw-r--r-- | synapse/handlers/message.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 5f88f84d38..7d28c2745c 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -569,6 +569,20 @@ class EventCreationHandler(object): extra_users (list(str)): Any extra users to notify about event """ + try: + yield self.auth.check_from_context(event, context) + except AuthError as err: + logger.warn("Denying new event %r because %s", event, err) + raise err + + # Ensure that we can round trip before trying to persist in db + try: + dump = ujson.dumps(unfreeze(event.content)) + ujson.loads(dump) + except Exception: + logger.exception("Failed to encode content: %r", event.content) + raise + yield self.action_generator.handle_push_actions_for_event( event, context ) @@ -610,8 +624,8 @@ class EventCreationHandler(object): ratelimit=True, extra_users=[], ): - """Called when we have fully built the event, and have already - calculated the push actions for the event. + """Called when we have fully built the event, have already + calculated the push actions for the event, and checked auth. This should only be run on master. """ @@ -620,20 +634,6 @@ class EventCreationHandler(object): if ratelimit: yield self.base_handler.ratelimit(requester) - try: - yield self.auth.check_from_context(event, context) - except AuthError as err: - logger.warn("Denying new event %r because %s", event, err) - raise err - - # Ensure that we can round trip before trying to persist in db - try: - dump = ujson.dumps(unfreeze(event.content)) - ujson.loads(dump) - except Exception: - logger.exception("Failed to encode content: %r", event.content) - raise - yield self.base_handler.maybe_kick_guest_users(event, context) if event.type == EventTypes.CanonicalAlias: |