diff options
author | Erik Johnston <erik@matrix.org> | 2019-09-11 11:16:17 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-09-11 11:18:04 +0100 |
commit | c64c3bb4c5b740e3f505708bc5dde0b5b29de6b8 (patch) | |
tree | 056a03f15e606a5074d4d1dfce198b03574609ff /synapse/handlers/message.py | |
parent | Update sample config (diff) | |
download | synapse-c64c3bb4c5b740e3f505708bc5dde0b5b29de6b8.tar.xz |
Fix how we check for self redaction
Diffstat (limited to 'synapse/handlers/message.py')
-rw-r--r-- | synapse/handlers/message.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 184170ef8b..f975909416 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -729,10 +729,24 @@ class EventCreationHandler(object): assert not self.config.worker_app if ratelimit: - is_admin_redaction = ( - event.type == EventTypes.Redaction - and event.sender != requester.user.to_string() - ) + # We check if this is a room admin redacting an event so that we + # can apply different ratelimiting. We do this by simply checking + # its not a self-redaction (to avoid having to look up whether the + # user is actually admin or not). + is_admin_redaction = False + if event.type == EventTypes.Redaction: + original_event = yield self.store.get_event( + event.redacts, + check_redacted=False, + get_prev_content=False, + allow_rejected=False, + allow_none=True, + ) + + is_admin_redaction = ( + original_event and event.sender != original_event.sender + ) + yield self.base_handler.ratelimit( requester, is_admin_redaction=is_admin_redaction ) |