feat: Enhance FCM token management by adding unsubscribe logic to prevent duplicate registrations
This commit is contained in:
@@ -713,7 +713,8 @@ class MessageRepository private constructor(private val context: Context) {
|
||||
packet.attachments,
|
||||
packet.chachaKey,
|
||||
privateKey,
|
||||
plainKeyAndNonce
|
||||
plainKeyAndNonce,
|
||||
messageId
|
||||
)
|
||||
|
||||
// 📸 Обрабатываем AVATAR attachments - сохраняем аватар отправителя
|
||||
@@ -1414,13 +1415,15 @@ class MessageRepository private constructor(private val context: Context) {
|
||||
attachments: List<MessageAttachment>,
|
||||
encryptedKey: String,
|
||||
privateKey: String,
|
||||
plainKeyAndNonce: ByteArray? = null
|
||||
plainKeyAndNonce: ByteArray? = null,
|
||||
messageId: String = ""
|
||||
) {
|
||||
val publicKey = currentAccount ?: return
|
||||
|
||||
for (attachment in attachments) {
|
||||
// Сохраняем только IMAGE, не FILE (файлы загружаются с CDN при необходимости)
|
||||
if (attachment.type == AttachmentType.IMAGE && attachment.blob.isNotEmpty()) {
|
||||
MessageLogger.logPhotoDecryptStart(messageId, attachment.id, attachment.blob.length)
|
||||
try {
|
||||
|
||||
// 1. Расшифровываем blob с ChaCha ключом сообщения
|
||||
@@ -1445,9 +1448,17 @@ class MessageRepository private constructor(private val context: Context) {
|
||||
privateKey = privateKey
|
||||
)
|
||||
|
||||
if (saved) {} else {}
|
||||
} else {}
|
||||
} catch (e: Exception) {}
|
||||
if (saved) {
|
||||
MessageLogger.logPhotoDecryptSuccess(messageId, attachment.id, true)
|
||||
} else {
|
||||
MessageLogger.logPhotoSaveFailed(messageId, attachment.id)
|
||||
}
|
||||
} else {
|
||||
MessageLogger.logPhotoDecryptFailed(messageId, attachment.id)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
MessageLogger.logPhotoDecryptError(messageId, attachment.id, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user