From 73dddea17feac650f4f09151cf446cbde2e378dc Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Thu, 9 Jun 2022 18:20:04 +0200 Subject: [PATCH] Make check more readable, also check for the sender --- roomserver/storage/shared/storage.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index ae87045d4..67dcfdf38 100644 --- a/roomserver/storage/shared/storage.go +++ b/roomserver/storage/shared/storage.go @@ -832,13 +832,14 @@ func (d *Database) handleRedactions( if err != nil { return nil, "", fmt.Errorf("unable to get powerlevels for room: %w", err) } - redactPL := pl.Redact + redactUser := pl.UserLevel(redactionEvent.Sender()) - // The power level of the redaction event’s sender is greater than or equal to the redact level. - userAllowed := redactUser >= redactPL - // The domain of the redaction event’s sender matches that of the original event’s sender. - originAllowed := redactedEvent.Origin() == redactionEvent.Origin() - if !originAllowed && !userAllowed { + switch { + case redactUser >= pl.Redact: + // The power level of the redaction event’s sender is greater than or equal to the redact level. + case redactedEvent.Origin() == redactionEvent.Origin() && redactedEvent.Sender() == redactionEvent.Sender(): + // The domain of the redaction event’s sender matches that of the original event’s sender. + default: return nil, "", nil }