diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2020-02-25 13:57:56 +0000 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2020-02-25 13:57:56 +0000 |
commit | 1dfbad8f10fa5b29dcf08673eee4e231b02c5713 (patch) | |
tree | bc95feba86dc32c482345a24c86d3b022975f549 /synapse/handlers/message.py | |
parent | Clean up some code in the retry logic (#6017) (diff) | |
parent | Merge pull request #6015 from matrix-org/erikj/ratelimit_admin_redaction (diff) | |
download | synapse-1dfbad8f10fa5b29dcf08673eee4e231b02c5713.tar.xz |
Merge pull request #6015 from matrix-org/erikj/ratelimit_admin_redaction
Diffstat (limited to 'synapse/handlers/message.py')
-rw-r--r-- | synapse/handlers/message.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 291eb9cb15..f158700c15 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -729,7 +729,27 @@ class EventCreationHandler(object): assert not self.config.worker_app if ratelimit: - yield self.base_handler.ratelimit(requester) + # We check if this is a room admin redacting an event so that we + # can apply different ratelimiting. We do this by simply checking + # it's 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 + ) yield self.base_handler.maybe_kick_guest_users(event, context) |