Ensure direct replies respect disappearing message timeout.

fork-5.53.8
Alex Hart 2022-04-19 09:59:40 -03:00
rodzic ab031d3dad
commit 631720f111
2 zmienionych plików z 15 dodań i 9 usunięć

Wyświetl plik

@ -1500,7 +1500,8 @@ public final class MessageContentProcessor {
try { try {
RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId(), null); RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId(), null);
ParentStoryId parentStoryId; ParentStoryId parentStoryId;
QuoteModel quoteModel = null; QuoteModel quoteModel = null;
long expiresInMillis = 0;
try { try {
MessageId storyMessageId = database.getStoryId(storyAuthorRecipient, storyContext.getSentTimestamp()); MessageId storyMessageId = database.getStoryId(storyAuthorRecipient, storyContext.getSentTimestamp());
@ -1509,8 +1510,9 @@ public final class MessageContentProcessor {
} else if (SignalDatabase.storySends().canReply(senderRecipient.getId(), storyContext.getSentTimestamp())) { } else if (SignalDatabase.storySends().canReply(senderRecipient.getId(), storyContext.getSentTimestamp())) {
MmsMessageRecord story = (MmsMessageRecord) database.getMessageRecord(storyMessageId.getId()); MmsMessageRecord story = (MmsMessageRecord) database.getMessageRecord(storyMessageId.getId());
parentStoryId = new ParentStoryId.DirectReply(storyMessageId.getId()); parentStoryId = new ParentStoryId.DirectReply(storyMessageId.getId());
quoteModel = new QuoteModel(storyContext.getSentTimestamp(), storyAuthorRecipient, "", false, story.getSlideDeck().asAttachments(), Collections.emptyList()); quoteModel = new QuoteModel(storyContext.getSentTimestamp(), storyAuthorRecipient, "", false, story.getSlideDeck().asAttachments(), Collections.emptyList());
expiresInMillis = TimeUnit.SECONDS.toMillis(message.getExpiresInSeconds());
} else { } else {
warn(content.getTimestamp(), "Story has reactions disabled. Dropping reaction."); warn(content.getTimestamp(), "Story has reactions disabled. Dropping reaction.");
return; return;
@ -1528,7 +1530,7 @@ public final class MessageContentProcessor {
parentStoryId, parentStoryId,
true, true,
-1, -1,
0, expiresInMillis,
false, false,
false, false,
content.isNeedsReceipt(), content.isNeedsReceipt(),
@ -1570,7 +1572,9 @@ public final class MessageContentProcessor {
try { try {
RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId(), null); RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId(), null);
ParentStoryId parentStoryId; ParentStoryId parentStoryId;
QuoteModel quoteModel = null; QuoteModel quoteModel = null;
long expiresInMillis = 0L;
try { try {
MessageId storyMessageId = database.getStoryId(storyAuthorRecipient, storyContext.getSentTimestamp()); MessageId storyMessageId = database.getStoryId(storyAuthorRecipient, storyContext.getSentTimestamp());
MmsMessageRecord story = (MmsMessageRecord) database.getMessageRecord(storyMessageId.getId()); MmsMessageRecord story = (MmsMessageRecord) database.getMessageRecord(storyMessageId.getId());
@ -1580,8 +1584,9 @@ public final class MessageContentProcessor {
if (message.getGroupContext().isPresent() ) { if (message.getGroupContext().isPresent() ) {
parentStoryId = new ParentStoryId.GroupReply(storyMessageId.getId()); parentStoryId = new ParentStoryId.GroupReply(storyMessageId.getId());
} else if (groupStory || SignalDatabase.storySends().canReply(senderRecipient.getId(), storyContext.getSentTimestamp())) { } else if (groupStory || SignalDatabase.storySends().canReply(senderRecipient.getId(), storyContext.getSentTimestamp())) {
parentStoryId = new ParentStoryId.DirectReply(storyMessageId.getId()); parentStoryId = new ParentStoryId.DirectReply(storyMessageId.getId());
quoteModel = new QuoteModel(storyContext.getSentTimestamp(), groupStory ? threadRecipient.getId() : storyAuthorRecipient, "", false, story.getSlideDeck().asAttachments(), Collections.emptyList()); quoteModel = new QuoteModel(storyContext.getSentTimestamp(), groupStory ? threadRecipient.getId() : storyAuthorRecipient, "", false, story.getSlideDeck().asAttachments(), Collections.emptyList());
expiresInMillis = TimeUnit.SECONDS.toMillis(message.getExpiresInSeconds());
} else { } else {
warn(content.getTimestamp(), "Story has replies disabled. Dropping reply."); warn(content.getTimestamp(), "Story has replies disabled. Dropping reply.");
return; return;
@ -1599,7 +1604,7 @@ public final class MessageContentProcessor {
parentStoryId, parentStoryId,
false, false,
-1, -1,
0, expiresInMillis,
false, false,
false, false,
content.isNeedsReceipt(), content.isNeedsReceipt(),

Wyświetl plik

@ -14,6 +14,7 @@ import org.thoughtcrime.securesms.mms.QuoteModel
import org.thoughtcrime.securesms.recipients.Recipient import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.recipients.RecipientId import org.thoughtcrime.securesms.recipients.RecipientId
import org.thoughtcrime.securesms.sms.MessageSender import org.thoughtcrime.securesms.sms.MessageSender
import java.util.concurrent.TimeUnit
class StoryDirectReplyRepository(context: Context) { class StoryDirectReplyRepository(context: Context) {
@ -49,7 +50,7 @@ class StoryDirectReplyRepository(context: Context) {
emptyList(), emptyList(),
System.currentTimeMillis(), System.currentTimeMillis(),
0, 0,
0L, TimeUnit.SECONDS.toMillis(recipient.expiresInSeconds.toLong()),
false, false,
0, 0,
StoryType.NONE, StoryType.NONE,