fix: treat self sends correctly when no contact information for ourself (#1318)

This commit is contained in:
0x330a 2023-09-07 16:54:38 +10:00 committed by GitHub
parent b4eb54ee89
commit 380d6694ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,17 +89,18 @@ class AttachmentDownloadJob(val attachmentID: Long, val databaseMessageID: Long)
} }
val threadRecipient = storage.getRecipientForThread(threadID) val threadRecipient = storage.getRecipientForThread(threadID)
val sender = if (messageDataProvider.isMmsOutgoing(databaseMessageID)) { val selfSend = messageDataProvider.isMmsOutgoing(databaseMessageID)
val sender = if (selfSend) {
storage.getUserPublicKey() storage.getUserPublicKey()
} else { } else {
messageDataProvider.getIndividualRecipientForMms(databaseMessageID)?.address?.serialize() messageDataProvider.getIndividualRecipientForMms(databaseMessageID)?.address?.serialize()
} }
val contact = sender?.let { storage.getContactWithSessionID(it) } 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) handleFailure(Error.NoSender, null)
return 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: // 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 // do not continue, but do not fail
return return