mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Enqueue downloads for stories we view on other devices.
This commit is contained in:
committed by
Cody Henthorne
parent
ea3fb774f8
commit
0bf5f15cf9
@@ -50,6 +50,7 @@ import org.thoughtcrime.securesms.database.SentStorySyncManifest;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.StickerDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.Mention;
|
||||
import org.thoughtcrime.securesms.database.model.MessageId;
|
||||
import org.thoughtcrime.securesms.database.model.MessageLogEntry;
|
||||
@@ -1317,15 +1318,28 @@ public final class MessageContentProcessor {
|
||||
private void handleSynchronizeViewedMessage(@NonNull List<ViewedMessage> viewedMessages, long envelopeTimestamp) {
|
||||
log(envelopeTimestamp, "Synchronize view message. Count: " + viewedMessages.size() + ", Timestamps: " + Stream.of(viewedMessages).map(ViewedMessage::getTimestamp).toList());
|
||||
|
||||
List<Long> toMarkViewed = Stream.of(viewedMessages)
|
||||
List<MessageRecord> records = Stream.of(viewedMessages)
|
||||
.map(message -> {
|
||||
RecipientId author = Recipient.externalPush(message.getSender()).getId();
|
||||
return SignalDatabase.mmsSms().getMessageFor(message.getTimestamp(), author);
|
||||
})
|
||||
.filter(message -> message != null && message.isMms())
|
||||
.toList();
|
||||
|
||||
List<Long> toMarkViewed = Stream.of(records)
|
||||
.map(MessageRecord::getId)
|
||||
.toList();
|
||||
|
||||
List<MediaMmsMessageRecord> toEnqueueDownload = Stream.of(records)
|
||||
.filter(MessageRecord::isMms)
|
||||
.map(it -> (MediaMmsMessageRecord) it)
|
||||
.filter(it -> it.getStoryType().isStory() && !it.getStoryType().isTextStory())
|
||||
.toList();
|
||||
|
||||
for (final MediaMmsMessageRecord mediaMmsMessageRecord : toEnqueueDownload) {
|
||||
Stories.enqueueAttachmentsFromStoryForDownloadSync(mediaMmsMessageRecord, false);
|
||||
}
|
||||
|
||||
SignalDatabase.mms().setIncomingMessagesViewed(toMarkViewed);
|
||||
SignalDatabase.mms().setOutgoingGiftsRevealed(toMarkViewed);
|
||||
|
||||
|
||||
@@ -154,8 +154,9 @@ object Stories {
|
||||
}.subscribeOn(Schedulers.io())
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@WorkerThread
|
||||
private fun enqueueAttachmentsFromStoryForDownloadSync(record: MmsMessageRecord, ignoreAutoDownloadConstraints: Boolean) {
|
||||
fun enqueueAttachmentsFromStoryForDownloadSync(record: MmsMessageRecord, ignoreAutoDownloadConstraints: Boolean) {
|
||||
SignalDatabase.attachments.getAttachmentsForMessage(record.id).filterNot { it.isSticker }.forEach {
|
||||
val job = AttachmentDownloadJob(record.id, it.attachmentId, ignoreAutoDownloadConstraints)
|
||||
ApplicationDependencies.getJobManager().add(job)
|
||||
|
||||
Reference in New Issue
Block a user