Fix redaction

The catch-all branch was applying where it wasn't meant to.
This commit is contained in:
Jonas Platte 2020-09-23 12:18:45 +02:00
parent f92428b2c2
commit 414161f0fd
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67

View File

@ -714,15 +714,39 @@ pub fn redact(value: &Value) -> Result<Value, Error> {
for key in map.clone().keys() {
match event_type.as_ref() {
"m.room.member" if key != "membership" => map.remove(key),
"m.room.create" if key != "creator" => map.remove(key),
"m.room.join_rules" if key != "join_rules" => map.remove(key),
"m.room.power_levels" if !ALLOWED_POWER_LEVELS_KEYS.contains(&key.as_ref()) => {
map.remove(key)
"m.room.member" => {
if key != "membership" {
map.remove(key);
}
}
"m.room.create" => {
if key != "creator" {
map.remove(key);
}
}
"m.room.join_rules" => {
if key != "join_rules" {
map.remove(key);
}
}
"m.room.power_levels" => {
if !ALLOWED_POWER_LEVELS_KEYS.contains(&key.as_ref()) {
map.remove(key);
}
}
"m.room.aliases" => {
if key != "aliases" {
map.remove(key);
}
}
"m.room.history_visibility" => {
if key != "history_visibility" {
map.remove(key);
}
}
_ => {
map.remove(key);
}
"m.room.aliases" if key != "aliases" => map.remove(key),
"m.room.history_visibility" if key != "history_visibility" => map.remove(key),
_ => map.remove(key),
};
}
}