Skip to content

Commit

Permalink
Fix issue with sending story viewed receipts.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Oct 24, 2022
1 parent 064f7ab commit b46e129
Showing 1 changed file with 6 additions and 6 deletions.
Expand Up @@ -137,14 +137,14 @@ public void onRun() throws IOException, UntrustedIdentityException {
boolean canSendNonStoryReceipts = TextSecurePreferences.isReadReceiptsEnabled(context);
boolean canSendStoryReceipts = SignalStore.storyValues().getViewedReceiptsEnabled();

List<MessageId> messageIds = new LinkedList<>();
List<MessageId> foundMessageIds = new LinkedList<>();
List<Long> messageSentTimestamps = new LinkedList<>();
List<StoryType> storyTypes = SignalDatabase.mms().getStoryTypes(messageIds);
List<StoryType> storyTypes = SignalDatabase.mms().getStoryTypes(this.messageIds);

for (int i = 0; i < storyTypes.size(); i++) {
StoryType storyType = storyTypes.get(i);
if ((storyType == StoryType.NONE && canSendNonStoryReceipts) || (storyType.isStory() && canSendStoryReceipts)) {
messageIds.add(this.messageIds.get(i));
foundMessageIds.add(this.messageIds.get(i));
messageSentTimestamps.add(this.messageSentTimestamps.get(i));
}
}
Expand All @@ -158,7 +158,7 @@ public void onRun() throws IOException, UntrustedIdentityException {
return;
}

if (messageIds.isEmpty()) {
if (foundMessageIds.isEmpty()) {
Log.w(TAG, "No messages in this batch are allowed to be sent!");
return;
}
Expand Down Expand Up @@ -206,8 +206,8 @@ public void onRun() throws IOException, UntrustedIdentityException {
receiptMessage,
recipient.needsPniSignature());

if (Util.hasItems(messageIds)) {
SignalDatabase.messageLog().insertIfPossible(recipientId, timestamp, result, ContentHint.IMPLICIT, messageIds, false);
if (Util.hasItems(foundMessageIds)) {
SignalDatabase.messageLog().insertIfPossible(recipientId, timestamp, result, ContentHint.IMPLICIT, foundMessageIds, false);
}
}

Expand Down

0 comments on commit b46e129

Please sign in to comment.