Fix receipt handling issue for stories.

This commit is contained in:
Alex Hart 2022-10-11 10:35:38 -03:00 committed by Greyson Parrelli
parent 7cc2029cd3
commit 1046265d23

View file

@ -2536,21 +2536,18 @@ public final class MessageContentProcessor {
@NonNull SignalServiceReceiptMessage message, @NonNull SignalServiceReceiptMessage message,
@NonNull Recipient senderRecipient) @NonNull Recipient senderRecipient)
{ {
boolean shouldOnlyProcessStories = Stories.isFeatureFlagEnabled() && !SignalStore.storyValues().isFeatureDisabled() && !TextSecurePreferences.isReadReceiptsEnabled(context); if (!TextSecurePreferences.isReadReceiptsEnabled(context)) {
if (!TextSecurePreferences.isReadReceiptsEnabled(context) && !shouldOnlyProcessStories) {
log("Ignoring viewed receipts for IDs: " + Util.join(message.getTimestamps(), ", ")); log("Ignoring viewed receipts for IDs: " + Util.join(message.getTimestamps(), ", "));
return; return;
} }
log(TAG, "Processing viewed receipts. Sender: " + senderRecipient.getId() + ", Device: " + content.getSenderDevice() + ", Only Stories: " + shouldOnlyProcessStories + ", Timestamps: " + Util.join(message.getTimestamps(), ", ")); log(TAG, "Processing viewed receipts. Sender: " + senderRecipient.getId() + ", Device: " + content.getSenderDevice() + ", Timestamps: " + Util.join(message.getTimestamps(), ", "));
List<SyncMessageId> ids = Stream.of(message.getTimestamps()) List<SyncMessageId> ids = Stream.of(message.getTimestamps())
.map(t -> new SyncMessageId(senderRecipient.getId(), t)) .map(t -> new SyncMessageId(senderRecipient.getId(), t))
.toList(); .toList();
Collection<SyncMessageId> unhandled = shouldOnlyProcessStories ? SignalDatabase.mmsSms().incrementViewedStoryReceiptCounts(ids, content.getTimestamp()) Collection<SyncMessageId> unhandled = SignalDatabase.mmsSms().incrementViewedReceiptCounts(ids, content.getTimestamp());
: SignalDatabase.mmsSms().incrementViewedReceiptCounts(ids, content.getTimestamp());
Set<SyncMessageId> handled = new HashSet<>(ids); Set<SyncMessageId> handled = new HashSet<>(ids);
handled.removeAll(unhandled); handled.removeAll(unhandled);