From e5082f662cc0446f7bb34376caaaae91f206cf7d Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 10 Jul 2019 14:19:59 +0200 Subject: [PATCH] Fix actually done TODO --- .../room/send/LocalEchoEventFactory.kt | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt index 9d7cf089..5f060284 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt @@ -98,24 +98,27 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials newBodyAutoMarkdown: Boolean, msgType: String, compatibilityText: String): Event { - // TODO Format newBodyText - var newContent = MessageTextContent( - type = MessageType.MSGTYPE_TEXT, - body = newBodyText - ) - if (newBodyAutoMarkdown) { - val parser = Parser.builder().build() + val newContent = if (newBodyAutoMarkdown) { val document = parser.parse(newBodyText) - val renderer = HtmlRenderer.builder().build() val htmlText = renderer.render(document) if (isFormattedTextPertinent(newBodyText, htmlText)) { - newContent = MessageTextContent( + MessageTextContent( type = MessageType.MSGTYPE_TEXT, format = MessageType.FORMAT_MATRIX_HTML, body = newBodyText, formattedBody = htmlText ) + } else { + MessageTextContent( + type = MessageType.MSGTYPE_TEXT, + body = newBodyText + ) } + } else { + MessageTextContent( + type = MessageType.MSGTYPE_TEXT, + body = newBodyText + ) } val content = MessageTextContent( @@ -226,7 +229,7 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials type = MessageType.MSGTYPE_FILE, body = attachment.name ?: "file", info = FileInfo( - mimeType = attachment.mimeType.takeIf { it.isNotBlank() } ?: "application/octet-stream", + mimeType = attachment.mimeType.takeIf { it.isNotBlank() } ?: "application/octet-stream", size = attachment.size ), url = attachment.path