Merge pull request #298 from vector-im/feature/quote
Fix issue when quoting event in e2e rooms (Fixes #295)
This commit is contained in:
commit
72e5aa981a
|
@ -42,7 +42,7 @@ interface SendService {
|
||||||
* @param formattedText The formatted body using MessageType#FORMAT_MATRIX_HTML
|
* @param formattedText The formatted body using MessageType#FORMAT_MATRIX_HTML
|
||||||
* @return a [Cancelable]
|
* @return a [Cancelable]
|
||||||
*/
|
*/
|
||||||
fun sendFormattedTextMessage(text: String,formattedText: String): Cancelable
|
fun sendFormattedTextMessage(text: String, formattedText: String): Cancelable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to send a media asynchronously.
|
* Method to send a media asynchronously.
|
||||||
|
|
|
@ -54,6 +54,19 @@ internal class DefaultSendService @Inject constructor(private val context: Conte
|
||||||
val event = localEchoEventFactory.createTextEvent(roomId, msgType, text, autoMarkdown).also {
|
val event = localEchoEventFactory.createTextEvent(roomId, msgType, text, autoMarkdown).also {
|
||||||
saveLocalEcho(it)
|
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
|
// Encrypted room handling
|
||||||
return if (cryptoService.isRoomEncrypted(roomId)) {
|
return if (cryptoService.isRoomEncrypted(roomId)) {
|
||||||
Timber.v("Send event in encrypted room")
|
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)
|
TimelineSendEventWorkCommon.postSequentialWorks(context, roomId, encryptWork, sendWork)
|
||||||
CancelableWork(context, encryptWork.id)
|
CancelableWork(context, encryptWork.id)
|
||||||
} else {
|
} 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 {
|
override fun sendMedias(attachments: List<ContentAttachmentData>): Cancelable {
|
||||||
val cancelableBag = CancelableBag()
|
val cancelableBag = CancelableBag()
|
||||||
attachments.forEach {
|
attachments.forEach {
|
||||||
|
|
|
@ -254,7 +254,7 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials
|
||||||
// </blockquote>
|
// </blockquote>
|
||||||
// </mx-reply>
|
// </mx-reply>
|
||||||
// This is where the reply goes.
|
// This is where the reply goes.
|
||||||
val body = bodyForReply(eventReplied.content.toModel<MessageContent>())
|
val body = bodyForReply(eventReplied.getClearContent().toModel<MessageContent>())
|
||||||
val replyFallbackTemplateFormatted = """
|
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
|
<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)
|
""".trimIndent().format(permalink, userLink, userId, body.second ?: body.first, replyText)
|
||||||
|
|
|
@ -233,7 +233,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||||
SendMode.QUOTE -> {
|
SendMode.QUOTE -> {
|
||||||
val messageContent: MessageContent? =
|
val messageContent: MessageContent? =
|
||||||
state.selectedEvent?.annotations?.editSummary?.aggregatedContent?.toModel()
|
state.selectedEvent?.annotations?.editSummary?.aggregatedContent?.toModel()
|
||||||
?: state.selectedEvent?.root?.content.toModel()
|
?: state.selectedEvent?.root?.getClearContent().toModel()
|
||||||
val textMsg = messageContent?.body
|
val textMsg = messageContent?.body
|
||||||
|
|
||||||
val finalText = legacyRiotQuoteText(textMsg, action.text)
|
val finalText = legacyRiotQuoteText(textMsg, action.text)
|
||||||
|
|
Loading…
Reference in New Issue