supporting local echos for text replies
This commit is contained in:
parent
d67d1eda13
commit
ae693f7ee8
|
@ -11,14 +11,28 @@ internal class LocalEchoMapper(private val metaMapper: MetaMapper) {
|
|||
fun MessageService.LocalEcho.toMessage(member: RoomMember): RoomEvent {
|
||||
return when (val message = this.message) {
|
||||
is MessageService.Message.TextMessage -> {
|
||||
RoomEvent.Message(
|
||||
val mappedMessage = RoomEvent.Message(
|
||||
eventId = this.eventId ?: EventId(this.localId),
|
||||
content = message.content.body,
|
||||
author = member,
|
||||
utcTimestamp = message.timestampUtc,
|
||||
meta = metaMapper.toMeta(this)
|
||||
)
|
||||
|
||||
when (val reply = message.reply) {
|
||||
null -> mappedMessage
|
||||
else -> RoomEvent.Reply(
|
||||
mappedMessage, RoomEvent.Message(
|
||||
eventId = reply.eventId,
|
||||
content = reply.originalMessage,
|
||||
author = reply.author,
|
||||
utcTimestamp = reply.timestampUtc,
|
||||
meta = MessageMeta.FromServer
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
is MessageService.Message.ImageMessage -> {
|
||||
RoomEvent.Image(
|
||||
eventId = this.eventId ?: EventId(this.localId),
|
||||
|
|
|
@ -123,14 +123,15 @@ internal class MessengerViewModel(
|
|||
timestampUtc = clock.millis(),
|
||||
reply = copy.reply?.let {
|
||||
MessageService.Message.TextMessage.Reply(
|
||||
authorId = it.author.id,
|
||||
author = it.author,
|
||||
originalMessage = when (it) {
|
||||
is RoomEvent.Image -> TODO()
|
||||
is RoomEvent.Reply -> TODO()
|
||||
is RoomEvent.Message -> it.content
|
||||
},
|
||||
copy.value,
|
||||
it.eventId
|
||||
replyContent = copy.value,
|
||||
eventId = it.eventId,
|
||||
timestampUtc = it.utcTimestamp,
|
||||
)
|
||||
}
|
||||
)
|
||||
|
|
|
@ -43,10 +43,11 @@ interface MessageService : MatrixService {
|
|||
) : Message {
|
||||
@Serializable
|
||||
data class Reply(
|
||||
val authorId: UserId,
|
||||
val author: RoomMember,
|
||||
val originalMessage: String,
|
||||
val replyContent: String,
|
||||
val eventId: EventId
|
||||
val eventId: EventId,
|
||||
val timestampUtc: Long,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -157,9 +157,9 @@ class ApiMessageMapper {
|
|||
)
|
||||
|
||||
else -> ApiMessage.TextMessage.TextContent(
|
||||
body = buildReplyFallback(reply.originalMessage, reply.authorId, reply.replyContent),
|
||||
body = buildReplyFallback(reply.originalMessage, reply.author.id, reply.replyContent),
|
||||
relatesTo = ApiMessage.RelatesTo(ApiMessage.RelatesTo.InReplyTo(reply.eventId)),
|
||||
formattedBody = buildFormattedReply(reply.authorId, reply.originalMessage, reply.replyContent, this.roomId, reply.eventId),
|
||||
formattedBody = buildFormattedReply(reply.author.id, reply.originalMessage, reply.replyContent, this.roomId, reply.eventId),
|
||||
format = "org.matrix.custom.html"
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue