simplify room v11 top level redacts key
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
820cf3b9af
commit
67b4f19c60
2 changed files with 52 additions and 26 deletions
|
@ -307,21 +307,6 @@ impl Service {
|
|||
let mut pdu_id = shortroomid.to_be_bytes().to_vec();
|
||||
pdu_id.extend_from_slice(&count2.to_be_bytes());
|
||||
|
||||
// https://spec.matrix.org/v1.9/rooms/v11/#moving-the-redacts-property-of-mroomredaction-events-to-a-content-property
|
||||
// For backwards-compatibility with older clients,
|
||||
// servers should add a redacts property to the top level of m.room.redaction
|
||||
// events in when serving such events over the Client-Server API.
|
||||
if pdu.kind == TimelineEventType::RoomRedaction
|
||||
&& services().rooms.state.get_room_version(&pdu.room_id)? == RoomVersionId::V11
|
||||
{
|
||||
let content = serde_json::from_str::<RoomRedactionEventContent>(pdu.content.get())
|
||||
.map_err(|_| Error::bad_database("Invalid content in redaction pdu."))?;
|
||||
|
||||
if let Some(redact_id) = &content.redacts {
|
||||
pdu_json.insert("redacts".to_owned(), CanonicalJsonValue::String(redact_id.to_string()));
|
||||
}
|
||||
}
|
||||
|
||||
// Insert pdu
|
||||
self.db.append_pdu(&pdu_id, pdu, &pdu_json, count2)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue