Merge pull request #298 from vector-im/feature/quote

Fix issue when quoting event in e2e rooms (Fixes #295)
This commit is contained in:
Benoit Marty 2019-07-04 14:49:53 +02:00 committed by GitHub
commit 72e5aa981a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 19 deletions

View File

@ -42,7 +42,7 @@ interface SendService {
* @param formattedText The formatted body using MessageType#FORMAT_MATRIX_HTML
* @return a [Cancelable]
*/
fun sendFormattedTextMessage(text: String,formattedText: String): Cancelable
fun sendFormattedTextMessage(text: String, formattedText: String): Cancelable
/**
* Method to send a media asynchronously.

View File

@ -54,6 +54,19 @@ internal class DefaultSendService @Inject constructor(private val context: Conte
val event = localEchoEventFactory.createTextEvent(roomId, msgType, text, autoMarkdown).also {
saveLocalEcho(it)
}
return sendEvent(event)
}
override fun sendFormattedTextMessage(text: String, formattedText: String): Cancelable {
val event = localEchoEventFactory.createFormattedTextEvent(roomId, text, formattedText).also {
saveLocalEcho(it)
}
return sendEvent(event)
}
private fun sendEvent(event: Event): Cancelable {
// Encrypted room handling
return if (cryptoService.isRoomEncrypted(roomId)) {
Timber.v("Send event in encrypted room")
@ -62,25 +75,12 @@ internal class DefaultSendService @Inject constructor(private val context: Conte
TimelineSendEventWorkCommon.postSequentialWorks(context, roomId, encryptWork, sendWork)
CancelableWork(context, encryptWork.id)
} else {
sendEvent(event)
val sendWork = createSendEventWork(event)
TimelineSendEventWorkCommon.postWork(context, roomId, sendWork)
CancelableWork(context, sendWork.id)
}
}
private fun sendEvent(event: Event): Cancelable {
val sendWork = createSendEventWork(event)
TimelineSendEventWorkCommon.postWork(context, roomId, sendWork)
return CancelableWork(context, sendWork.id)
}
override fun sendFormattedTextMessage(text: String, formattedText: String): Cancelable {
val event = localEchoEventFactory.createFormattedTextEvent(roomId, text, formattedText).also {
saveLocalEcho(it)
}
val sendWork = createSendEventWork(event)
TimelineSendEventWorkCommon.postWork(context, roomId, sendWork)
return CancelableWork(context, sendWork.id)
}
override fun sendMedias(attachments: List<ContentAttachmentData>): Cancelable {
val cancelableBag = CancelableBag()
attachments.forEach {

View File

@ -254,7 +254,7 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials
// </blockquote>
// </mx-reply>
// This is where the reply goes.
val body = bodyForReply(eventReplied.content.toModel<MessageContent>())
val body = bodyForReply(eventReplied.getClearContent().toModel<MessageContent>())
val replyFallbackTemplateFormatted = """
<mx-reply><blockquote><a href="%s">${stringProvider.getString(R.string.message_reply_to_prefix)}</a><a href="%s">%s</a><br />%s</blockquote></mx-reply>%s
""".trimIndent().format(permalink, userLink, userId, body.second ?: body.first, replyText)

View File

@ -233,7 +233,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
SendMode.QUOTE -> {
val messageContent: MessageContent? =
state.selectedEvent?.annotations?.editSummary?.aggregatedContent?.toModel()
?: state.selectedEvent?.root?.content.toModel()
?: state.selectedEvent?.root?.getClearContent().toModel()
val textMsg = messageContent?.body
val finalText = legacyRiotQuoteText(textMsg, action.text)