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 b9eaf8d50d..451081fd1a 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