events: Don't add reply fallback in thread fallback

This commit is contained in:
Kévin Commaille 2022-06-21 09:15:42 +02:00 committed by Kévin Commaille
parent 92f862e279
commit 9b2117cbf6

View File

@ -239,14 +239,17 @@ impl RoomMessageEventContent {
/// thread is created. If it doesn't, a new thread with `previous_message` as the root is /// thread is created. If it doesn't, a new thread with `previous_message` as the root is
/// created. /// created.
/// ///
/// If `message` is a text or notice message, it is modified to include the rich reply fallback. /// If `message` is a text or notice message, and this is a reply in the thread, it is modified
/// to include the rich reply fallback.
#[cfg(feature = "unstable-msc3440")] #[cfg(feature = "unstable-msc3440")]
pub fn for_thread( pub fn for_thread(
message: MessageType, message: MessageType,
previous_message: &OriginalRoomMessageEvent, previous_message: &OriginalRoomMessageEvent,
is_reply: ReplyInThread, is_reply: ReplyInThread,
) -> Self { ) -> Self {
let msgtype = match message { let msgtype = if is_reply == ReplyInThread::Yes {
// If this is a real reply, add the rich reply fallback.
match message {
MessageType::Text(TextMessageEventContent { body, formatted, .. }) => { MessageType::Text(TextMessageEventContent { body, formatted, .. }) => {
let (body, html_body) = reply::plain_and_formatted_reply_body( let (body, html_body) = reply::plain_and_formatted_reply_body(
body, body,
@ -266,6 +269,9 @@ impl RoomMessageEventContent {
MessageType::Notice(NoticeMessageEventContent::html(body, html_body)) MessageType::Notice(NoticeMessageEventContent::html(body, html_body))
} }
_ => message, _ => message,
}
} else {
message
}; };
let thread_root = if let Some(Relation::Thread(Thread { event_id, .. })) = let thread_root = if let Some(Relation::Thread(Thread { event_id, .. })) =