Fix unnecessary timer change message insert on sync messages.

This commit is contained in:
Cody Henthorne
2024-09-03 15:43:01 -04:00
committed by GitHub
parent 2c7668253e
commit 0c4725dfa7
3 changed files with 10 additions and 4 deletions

View File

@@ -343,7 +343,7 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
TextUtils.concat(
colorize("DeleteSync", capabilities.deleteSync),
", ",
colorize("Expire Timer Version", capabilities.versionedExpirationTimer)
colorize("VersionedExpirationTimer", capabilities.versionedExpirationTimer)
)
} else {
"Recipient not found!"

View File

@@ -35,6 +35,7 @@ public final class LogSectionCapabilities implements LogSection {
StringBuilder builder = new StringBuilder().append("-- Local").append("\n")
.append("DeleteSync: ").append(localCapabilities.getDeleteSync()).append("\n")
.append("VersionedExpirationTimer: ").append(localCapabilities.getVersionedExpirationTimer()).append("\n")
.append("\n")
.append("-- Global").append("\n");

View File

@@ -130,6 +130,7 @@ import java.util.Optional
import java.util.UUID
import java.util.concurrent.TimeUnit
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
object SyncMessageProcessor {
@@ -669,7 +670,7 @@ object SyncMessageProcessor {
@Throws(MmsException::class)
private fun handleSynchronizeSentExpirationUpdate(sent: Sent, sideEffect: Boolean = false): Long {
log(sent.timestamp!!, "Synchronize sent expiration update.")
log(sent.timestamp!!, "Synchronize sent expiration update. sideEffect: $sideEffect")
val groupId: GroupId? = getSyncMessageDestination(sent).groupId.orNull()
@@ -694,8 +695,12 @@ object SyncMessageProcessor {
SignalDatabase.messages.markAsSent(messageId, true)
} else if (sent.message!!.expireTimerVersion!! >= recipient.expireTimerVersion) {
SignalDatabase.recipients.setExpireMessages(recipient.id, sent.message!!.expireTimerDuration.inWholeSeconds.toInt(), sent.message!!.expireTimerVersion!!)
val messageId: Long = SignalDatabase.messages.insertMessageOutbox(expirationUpdateMessage, threadId, false, null)
SignalDatabase.messages.markAsSent(messageId, true)
if (sent.message!!.expireTimerDuration != recipient.expiresInSeconds.seconds) {
log(sent.timestamp!!, "Not inserted update message as timer value did not change")
val messageId: Long = SignalDatabase.messages.insertMessageOutbox(expirationUpdateMessage, threadId, false, null)
SignalDatabase.messages.markAsSent(messageId, true)
}
} else {
warn(sent.timestamp!!, "[SynchronizeExpiration] Ignoring expire timer update with old version. Received: ${sent.message!!.expireTimerVersion}, Current: ${recipient.expireTimerVersion}")
}