mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-19 17:56:19 +03:00
Fix how we check for self redaction
This commit is contained in:
parent
059369dd04
commit
fe8636b79e
1 changed files with 18 additions and 4 deletions
|
@ -726,10 +726,24 @@ class EventCreationHandler(object):
|
||||||
assert not self.config.worker_app
|
assert not self.config.worker_app
|
||||||
|
|
||||||
if ratelimit:
|
if ratelimit:
|
||||||
is_admin_redaction = (
|
# We check if this is a room admin redacting an event so that we
|
||||||
event.type == EventTypes.Redaction
|
# can apply different ratelimiting. We do this by simply checking
|
||||||
and event.sender != requester.user.to_string()
|
# 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(
|
yield self.base_handler.ratelimit(
|
||||||
requester, is_admin_redaction=is_admin_redaction
|
requester, is_admin_redaction=is_admin_redaction
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue