fix: only resume AttachmentDownloadJobs and fix boolean logic on returning early in download job

This commit is contained in:
jubb 2021-07-09 15:17:07 +10:00
parent 9dfd051e63
commit 1ee1d1795d
2 changed files with 3 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import androidx.appcompat.app.AlertDialog
import kotlinx.android.synthetic.main.dialog_download.view.*
import network.loki.messenger.R
import org.session.libsession.messaging.contacts.Contact
import org.session.libsession.messaging.jobs.AttachmentDownloadJob
import org.session.libsession.messaging.jobs.JobQueue
import org.session.libsession.utilities.recipients.Recipient
import org.thoughtcrime.securesms.conversation.v2.utilities.BaseDialog
@ -42,7 +43,7 @@ class DownloadDialog(private val recipient: Recipient) : BaseDialog() {
val contact = contactDB.getContactWithSessionID(sessionID) ?: return
val threadID = DatabaseFactory.getThreadDatabase(requireContext()).getThreadIdIfExistsFor(recipient)
contactDB.setContactIsTrusted(contact, true, threadID)
JobQueue.shared.resumePendingJobs()
JobQueue.shared.resumePendingJobs(AttachmentDownloadJob.KEY)
dismiss()
}
}

View File

@ -76,7 +76,7 @@ class AttachmentDownloadJob(val attachmentID: Long, val databaseMessageID: Long)
handleFailure(Error.NoSender, null)
return
}
if (!threadRecipient.isGroupRecipient && (!contact.isTrusted || storage.getUserPublicKey() != sender.address.serialize())) {
if (!threadRecipient.isGroupRecipient && !(contact.isTrusted || storage.getUserPublicKey() != sender.address.serialize())) {
Log.e("Loki", "Thread isn't a group recipient, or contact isn't trusted or self-send")
return
}