Фикс парсинга 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,
isOutgoing = chatMsg.isOutgoing,
publicKey =
if (chatMsg.isOutgoing) currentUserPublicKey
else user.publicKey,
chatMsg.senderPublicKey.ifEmpty {
if (chatMsg.isOutgoing)
currentUserPublicKey
else user.publicKey
},
senderName = chatMsg.senderName,
attachments = chatMsg.attachments
)
}

View File

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