From b4853aa8fa5e3a24e3689fc88044de9915f6ab67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Mon, 4 Sep 2023 13:46:27 +0200 Subject: [PATCH] events: Add method on RoomMessageEventContent to apply a replacement --- crates/ruma-events/src/room/message.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/ruma-events/src/room/message.rs b/crates/ruma-events/src/room/message.rs index 14eef5b7..07ecdc33 100644 --- a/crates/ruma-events/src/room/message.rs +++ b/crates/ruma-events/src/room/message.rs @@ -420,6 +420,13 @@ impl RoomMessageEventContent { self.msgtype.body() } + /// Apply the given new content from a [`Replacement`] to this message. + pub fn apply_replacement(&mut self, new_content: RoomMessageEventContentWithoutRelation) { + let RoomMessageEventContentWithoutRelation { msgtype, mentions } = new_content; + self.msgtype = msgtype; + self.mentions = mentions; + } + /// Sanitize this message. /// /// If this message contains HTML, this removes the [tags and attributes] that are not listed in