Fix quote resolution failing for sent sync messages.

This commit is contained in:
Greyson Parrelli
2026-04-20 14:35:35 +00:00
parent 5f60adbe69
commit f4986273e4
2 changed files with 14 additions and 14 deletions
@@ -1612,7 +1612,7 @@ object DataMessageProcessor {
warn(timestamp, "Sender is not in the group! Thread: ${quotedMessage.threadId} Sender: ${senderRecipient.id}")
return false
}
} else if (senderRecipient.id != threadRecipient.id) {
} else if (senderRecipient.id != threadRecipient.id && !senderRecipient.isSelf) {
warn(timestamp, "Sender is not a part of the 1:1 thread! Thread: ${quotedMessage.threadId} Sender: ${senderRecipient.id}")
return false
}
@@ -248,7 +248,7 @@ object SyncMessageProcessor {
threadId = SignalDatabase.threads.getOrCreateThreadIdFor(getSyncMessageDestination(sent))
}
dataMessage.hasRemoteDelete -> DataMessageProcessor.handleRemoteDelete(context, envelope, dataMessage, senderRecipient.id, earlyMessageCacheEntry)
dataMessage.isMediaMessage -> threadId = handleSynchronizeSentMediaMessage(context, sent, envelope.clientTimestamp!!, senderRecipient, threadRecipient)
dataMessage.isMediaMessage -> threadId = handleSynchronizeSentMediaMessage(context, sent, envelope.clientTimestamp!!, senderRecipient)
dataMessage.pollCreate != null -> threadId = handleSynchronizedPollCreate(envelope, dataMessage, sent, senderRecipient)
dataMessage.pollVote != null -> {
DataMessageProcessor.handlePollVote(context, envelope, dataMessage, senderRecipient, earlyMessageCacheEntry)
@@ -846,12 +846,12 @@ object SyncMessageProcessor {
}
@Throws(MmsException::class, BadGroupIdException::class)
private fun handleSynchronizeSentMediaMessage(context: Context, sent: Sent, envelopeTimestamp: Long, senderRecipient: Recipient, threadRecipient: Recipient): Long {
private fun handleSynchronizeSentMediaMessage(context: Context, sent: Sent, envelopeTimestamp: Long, senderRecipient: Recipient): Long {
log(envelopeTimestamp, "Synchronize sent media message for " + sent.timestamp!!)
val recipient: Recipient = getSyncMessageDestination(sent)
val syncDestinationRecipient: Recipient = getSyncMessageDestination(sent)
val dataMessage: DataMessage = sent.message!!
val quoteModel: QuoteModel? = DataMessageProcessor.getValidatedQuote(context, envelopeTimestamp, dataMessage, senderRecipient, threadRecipient)
val quoteModel: QuoteModel? = DataMessageProcessor.getValidatedQuote(context, envelopeTimestamp, dataMessage, senderRecipient, syncDestinationRecipient)
val sticker: Attachment? = DataMessageProcessor.getStickerAttachment(envelopeTimestamp, dataMessage)
val sharedContacts: List<Contact> = DataMessageProcessor.getContacts(dataMessage)
val previews: List<LinkPreview> = DataMessageProcessor.getLinkPreviews(dataMessage.preview, dataMessage.body ?: "", false)
@@ -862,7 +862,7 @@ object SyncMessageProcessor {
val syncAttachments: List<Attachment> = listOfNotNull(sticker) + if (viewOnce) listOf<Attachment>(TombstoneAttachment.forNonQuote(MediaUtil.VIEW_ONCE)) else dataMessage.attachments.toPointersWithinLimit()
val mediaMessage = OutgoingMessage(
recipient = recipient,
recipient = syncDestinationRecipient,
body = dataMessage.body ?: "",
attachments = syncAttachments,
timestamp = sent.timestamp!!,
@@ -877,19 +877,19 @@ object SyncMessageProcessor {
isSecure = true
)
if (recipient.expiresInSeconds != dataMessage.expireTimerDuration.inWholeSeconds.toInt() || ((dataMessage.expireTimerVersion ?: -1) > recipient.expireTimerVersion)) {
if (syncDestinationRecipient.expiresInSeconds != dataMessage.expireTimerDuration.inWholeSeconds.toInt() || ((dataMessage.expireTimerVersion ?: -1) > syncDestinationRecipient.expireTimerVersion)) {
handleSynchronizeSentExpirationUpdate(sent, sideEffect = true)
}
val threadId = SignalDatabase.threads.getOrCreateThreadIdFor(recipient)
val threadId = SignalDatabase.threads.getOrCreateThreadIdFor(syncDestinationRecipient)
val insertResult = SignalDatabase.messages.insertMessageOutbox(mediaMessage, threadId, false, GroupReceiptTable.STATUS_UNKNOWN, null)
val messageId = insertResult.messageId
log(envelopeTimestamp, "Inserted sync message as messageId $messageId")
if (recipient.isGroup) {
updateGroupReceiptStatus(sent, messageId, recipient.requireGroupId())
if (syncDestinationRecipient.isGroup) {
updateGroupReceiptStatus(sent, messageId, syncDestinationRecipient.requireGroupId())
} else {
SignalDatabase.messages.markUnidentified(messageId, sent.isUnidentified(recipient.serviceId.orNull()))
SignalDatabase.messages.markUnidentified(messageId, sent.isUnidentified(syncDestinationRecipient.serviceId.orNull()))
}
SignalDatabase.messages.markAsSent(messageId, true)
@@ -899,9 +899,9 @@ object SyncMessageProcessor {
AppDependencies.expiringMessageManager.scheduleDeletion(messageId, true, sent.expirationStartTimestamp ?: 0, dataMessage.expireTimerDuration.inWholeMilliseconds)
}
if (recipient.isSelf) {
SignalDatabase.messages.incrementDeliveryReceiptCount(sent.timestamp!!, recipient.id, System.currentTimeMillis())
SignalDatabase.messages.incrementReadReceiptCount(sent.timestamp!!, recipient.id, System.currentTimeMillis())
if (syncDestinationRecipient.isSelf) {
SignalDatabase.messages.incrementDeliveryReceiptCount(sent.timestamp!!, syncDestinationRecipient.id, System.currentTimeMillis())
SignalDatabase.messages.incrementReadReceiptCount(sent.timestamp!!, syncDestinationRecipient.id, System.currentTimeMillis())
}
SignalDatabase.runPostSuccessfulTransaction {