diff options
author | Brendan Abolivier <babolivier@matrix.org> | 2019-06-14 19:37:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-14 19:37:59 +0100 |
commit | f12e1f029c5e805548438ffea2d125e0fdb39467 (patch) | |
tree | 11b748b10216dce60a554244fec530cd5ede7cfc /synapse/handlers/message.py | |
parent | Merge pull request #5461 from matrix-org/erikj/histograms_are_cumalitive (diff) | |
parent | Add plugin APIs for implementations of custom event rules. (diff) | |
download | synapse-f12e1f029c5e805548438ffea2d125e0fdb39467.tar.xz |
Merge pull request #5440 from matrix-org/babolivier/third_party_event_rules
Allow server admins to define implementations of extra rules for allowing or denying incoming events
Diffstat (limited to 'synapse/handlers/message.py')
-rw-r--r-- | synapse/handlers/message.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 0b02469ceb..11650dc80c 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright 2014 - 2016 OpenMarket Ltd -# Copyright 2017 - 2018 New Vector Ltd +# Copyright 2014-2016 OpenMarket Ltd +# Copyright 2017-2018 New Vector Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -248,6 +249,7 @@ class EventCreationHandler(object): self.action_generator = hs.get_action_generator() self.spam_checker = hs.get_spam_checker() + self.third_party_event_rules = hs.get_third_party_event_rules() self._block_events_without_consent_error = ( self.config.block_events_without_consent_error @@ -658,6 +660,14 @@ class EventCreationHandler(object): else: room_version = yield self.store.get_room_version(event.room_id) + event_allowed = yield self.third_party_event_rules.check_event_allowed( + event, context, + ) + if not event_allowed: + raise SynapseError( + 403, "This event is not allowed in this context", Codes.FORBIDDEN, + ) + try: yield self.auth.check_from_context(room_version, event, context) except AuthError as err: |