Ensure that attachments received during calls are autodownloaded afterwards.

The easiest way to do this is to add the constraint to the job itself,
when appropriate, so that we don't even run the job until you're done
with the call.
This commit is contained in:
Greyson Parrelli
2025-12-23 09:42:43 -05:00
committed by jeffrey-signal
parent 0b5fa18504
commit 3db8f5a2af
3 changed files with 30 additions and 24 deletions

View File

@@ -961,12 +961,12 @@ object DataMessageProcessor {
val downloadJobs: List<AttachmentDownloadJob> = insertResult.insertedAttachments.mapNotNull { (attachment, attachmentId) ->
if (attachment.isSticker) {
if (attachment.transferState != AttachmentTable.TRANSFER_PROGRESS_DONE) {
AttachmentDownloadJob(insertResult.messageId, attachmentId, true)
AttachmentDownloadJob(messageId = insertResult.messageId, attachmentId = attachmentId, forceDownload = true)
} else {
null
}
} else {
AttachmentDownloadJob(insertResult.messageId, attachmentId, false)
AttachmentDownloadJob(messageId = insertResult.messageId, attachmentId = attachmentId, forceDownload = false)
}
}
AppDependencies.jobManager.addAll(downloadJobs)

View File

@@ -496,9 +496,8 @@ object SyncMessageProcessor {
if (syncAttachments.isNotEmpty()) {
SignalDatabase.runPostSuccessfulTransaction {
for (attachment in attachments) {
AppDependencies.jobManager.add(AttachmentDownloadJob(messageId, attachment.attachmentId, false))
}
val downloadJobs: List<AttachmentDownloadJob> = attachments.map { AttachmentDownloadJob(messageId = messageId, attachmentId = it.attachmentId, forceDownload = it.isSticker) }
AppDependencies.jobManager.addAll(downloadJobs)
}
}
}
@@ -596,9 +595,8 @@ object SyncMessageProcessor {
}
SignalDatabase.runPostSuccessfulTransaction {
for (attachment in attachments) {
AppDependencies.jobManager.add(AttachmentDownloadJob(messageId, attachment.attachmentId, false))
}
val downloadJobs: List<AttachmentDownloadJob> = attachments.map { AttachmentDownloadJob(messageId = messageId, attachmentId = it.attachmentId, forceDownload = false) }
AppDependencies.jobManager.addAll(downloadJobs)
}
}
@@ -893,10 +891,8 @@ object SyncMessageProcessor {
}
SignalDatabase.runPostSuccessfulTransaction {
val downloadJobs: List<AttachmentDownloadJob> = attachments.map { AttachmentDownloadJob(messageId, it.attachmentId, false) }
for (attachment in attachments) {
AppDependencies.jobManager.addAll(downloadJobs)
}
val downloadJobs: List<AttachmentDownloadJob> = attachments.map { AttachmentDownloadJob(messageId = messageId, attachmentId = it.attachmentId, forceDownload = it.isSticker) }
AppDependencies.jobManager.addAll(downloadJobs)
}
return threadId