From 380d6694eac54560155b8155f32c4f4052a0cf2c Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Thu, 7 Sep 2023 16:54:38 +1000 Subject: [PATCH] fix: treat self sends correctly when no contact information for ourself (#1318) --- .../libsession/messaging/jobs/AttachmentDownloadJob.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libsession/src/main/java/org/session/libsession/messaging/jobs/AttachmentDownloadJob.kt b/libsession/src/main/java/org/session/libsession/messaging/jobs/AttachmentDownloadJob.kt index b9eaf8d50..451081fd1 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/jobs/AttachmentDownloadJob.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/jobs/AttachmentDownloadJob.kt @@ -89,17 +89,18 @@ class AttachmentDownloadJob(val attachmentID: Long, val databaseMessageID: Long) } val threadRecipient = storage.getRecipientForThread(threadID) - val sender = if (messageDataProvider.isMmsOutgoing(databaseMessageID)) { + val selfSend = messageDataProvider.isMmsOutgoing(databaseMessageID) + val sender = if (selfSend) { storage.getUserPublicKey() } else { messageDataProvider.getIndividualRecipientForMms(databaseMessageID)?.address?.serialize() } val contact = sender?.let { storage.getContactWithSessionID(it) } - if (threadRecipient == null || sender == null || contact == null) { + if (threadRecipient == null || sender == null || (contact == null && !selfSend)) { handleFailure(Error.NoSender, null) return } - if (!threadRecipient.isGroupRecipient && (!contact.isTrusted && storage.getUserPublicKey() != sender)) { + if (!threadRecipient.isGroupRecipient && (contact?.isTrusted == true || storage.getUserPublicKey() != sender)) { // if we aren't receiving a group message, a message from ourselves (self-send) and the contact sending is not trusted: // do not continue, but do not fail return