Фикс парсинга reply в группах

This commit is contained in:
2026-03-05 13:45:54 +05:00
parent eccaf018cf
commit 2d2638235c
2 changed files with 20 additions and 5 deletions

View File

@@ -535,8 +535,12 @@ fun ChatDetailScreen(
timestamp = chatMsg.timestamp.time, timestamp = chatMsg.timestamp.time,
isOutgoing = chatMsg.isOutgoing, isOutgoing = chatMsg.isOutgoing,
publicKey = publicKey =
if (chatMsg.isOutgoing) currentUserPublicKey chatMsg.senderPublicKey.ifEmpty {
else user.publicKey, if (chatMsg.isOutgoing)
currentUserPublicKey
else user.publicKey
},
senderName = chatMsg.senderName,
attachments = chatMsg.attachments attachments = chatMsg.attachments
) )
} }

View File

@@ -1902,13 +1902,19 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
_replyMessages.value = _replyMessages.value =
messages.map { msg -> messages.map { msg ->
val resolvedPublicKey =
msg.senderPublicKey.trim().ifEmpty {
if (msg.isOutgoing) sender else opponent
}
ReplyMessage( ReplyMessage(
messageId = msg.id, messageId = msg.id,
text = msg.text, text = msg.text,
timestamp = msg.timestamp.time, timestamp = msg.timestamp.time,
isOutgoing = msg.isOutgoing, isOutgoing = msg.isOutgoing,
// Если сообщение от меня - мой publicKey, иначе - собеседника // В группах senderPublicKey содержит автора сообщения, а opponent = ключ группы.
publicKey = if (msg.isOutgoing) sender else opponent, // Для desktop parity в reply JSON нужен именно ключ автора.
publicKey = resolvedPublicKey,
senderName = msg.senderName,
attachments = attachments =
msg.attachments msg.attachments
.filter { it.type != AttachmentType.MESSAGES } .filter { it.type != AttachmentType.MESSAGES }
@@ -1924,12 +1930,17 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
_replyMessages.value = _replyMessages.value =
messages.map { msg -> messages.map { msg ->
val resolvedPublicKey =
msg.senderPublicKey.trim().ifEmpty {
if (msg.isOutgoing) sender else opponent
}
ReplyMessage( ReplyMessage(
messageId = msg.id, messageId = msg.id,
text = msg.text, text = msg.text,
timestamp = msg.timestamp.time, timestamp = msg.timestamp.time,
isOutgoing = msg.isOutgoing, isOutgoing = msg.isOutgoing,
publicKey = if (msg.isOutgoing) sender else opponent, publicKey = resolvedPublicKey,
senderName = msg.senderName,
attachments = attachments =
msg.attachments msg.attachments
.filter { it.type != AttachmentType.MESSAGES } .filter { it.type != AttachmentType.MESSAGES }