Omit reply fallback when editing replies, as demanded by spec

Change-Id: Iec1567c8c7564a06d22171b8f9451a77f438aeac
This commit is contained in:
SpiritCroc 2022-11-18 12:39:42 +01:00
parent 6c4c35158b
commit a32fc6bbcb

View File

@ -307,6 +307,7 @@ internal class LocalEchoEventFactory @Inject constructor(
) )
} }
@Suppress("UNUSED_PARAMETER")
fun createReplaceTextOfReply( fun createReplaceTextOfReply(
roomId: String, roomId: String,
eventReplaced: TimelineEvent, eventReplaced: TimelineEvent,
@ -317,6 +318,9 @@ internal class LocalEchoEventFactory @Inject constructor(
compatibilityText: String, compatibilityText: String,
additionalContent: Content? = null, additionalContent: Content? = null,
): Event { ): Event {
// Reply edits should omit the reply fallback: https://spec.matrix.org/v1.4/client-server-api/#edits-of-replies
// Element Android didn't follow the spec since they didn't support rendering rich replies...
/*
val permalink = permalinkFactory.createPermalink(roomId, originalEvent.root.eventId ?: "", false) val permalink = permalinkFactory.createPermalink(roomId, originalEvent.root.eventId ?: "", false)
val userLink = originalEvent.root.senderId?.let { permalinkFactory.createPermalink(it, false) } ?: "" val userLink = originalEvent.root.senderId?.let { permalinkFactory.createPermalink(it, false) } ?: ""
@ -335,7 +339,9 @@ internal class LocalEchoEventFactory @Inject constructor(
// //
// > <@alice:example.org> This is the original body // > <@alice:example.org> This is the original body
// //
val replyFallback = buildReplyFallback(body, originalEvent.root.senderId ?: "", newBodyText) */
val replyFormatted = markdownParser.parse(newBodyText, force = true, advanced = autoMarkdown).takeFormatted()
return createMessageEvent( return createMessageEvent(
roomId, roomId,
@ -346,7 +352,7 @@ internal class LocalEchoEventFactory @Inject constructor(
newContent = MessageTextContent( newContent = MessageTextContent(
msgType = msgType, msgType = msgType,
format = MessageFormat.FORMAT_MATRIX_HTML, format = MessageFormat.FORMAT_MATRIX_HTML,
body = replyFallback, body = newBodyText,
formattedBody = replyFormatted formattedBody = replyFormatted
) )
.toContent() .toContent()