mirror of
https://github.com/element-hq/synapse.git
synced 2026-05-31 19:44:29 +00:00
Handle MSC4242 in redact
This commit is contained in:
@@ -61,6 +61,8 @@ pub mod event_field {
|
||||
pub const REPLACES_STATE: &str = "replaces_state";
|
||||
/// Event field: msc4354_sticky
|
||||
pub const MSC4354_STICKY: &str = "msc4354_sticky";
|
||||
// Event field: prev_state_events
|
||||
pub const PREV_STATE_EVENTS: &str = "prev_state_events";
|
||||
}
|
||||
|
||||
pub mod unsigned_field {
|
||||
|
||||
@@ -24,8 +24,10 @@ use super::constants::{
|
||||
redaction_field,
|
||||
unsigned_field::AGE_TS,
|
||||
};
|
||||
use crate::canonical_json::CanonicalizationOptions;
|
||||
use crate::room_versions::{EventFormatVersions, RoomVersion};
|
||||
use crate::{
|
||||
canonical_json::CanonicalizationOptions, events::constants::event_field::PREV_STATE_EVENTS,
|
||||
};
|
||||
|
||||
/// Calculates the event_id of an event.
|
||||
///
|
||||
@@ -99,7 +101,6 @@ pub fn redact(event: &Value, room_version: &RoomVersion) -> anyhow::Result<Value
|
||||
(STATE_KEY),
|
||||
(DEPTH),
|
||||
(PREV_EVENTS),
|
||||
(AUTH_EVENTS),
|
||||
(ORIGIN_SERVER_TS),
|
||||
]);
|
||||
|
||||
@@ -108,6 +109,14 @@ pub fn redact(event: &Value, room_version: &RoomVersion) -> anyhow::Result<Value
|
||||
allowed_keys.extend([PREV_STATE, MEMBERSHIP, ORIGIN]);
|
||||
}
|
||||
|
||||
// Room versions with MSC4242 have `prev_state_events` instead of
|
||||
// `auth_events`.
|
||||
if room_version.msc4242_state_dags {
|
||||
allowed_keys.insert(PREV_STATE_EVENTS);
|
||||
} else {
|
||||
allowed_keys.insert(AUTH_EVENTS);
|
||||
}
|
||||
|
||||
let event_type = event
|
||||
.get(TYPE)
|
||||
.with_context(|| format!("Missing {TYPE} field in json"))?
|
||||
|
||||
Reference in New Issue
Block a user