Fix scheduled message changing disappearing messages bug.

This commit is contained in:
Cody Henthorne 2023-03-06 09:47:12 -05:00 committed by GitHub
parent 33ab25a557
commit 6e8f3d1e71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View file

@ -42,6 +42,9 @@
</option>
</JavaCodeStyleSettings>
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value />
</option>
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
</JetCodeStyleSettings>

View file

@ -24,6 +24,7 @@ import org.signal.core.util.optionalString
import org.signal.core.util.or
import org.signal.core.util.readToSet
import org.signal.core.util.readToSingleBoolean
import org.signal.core.util.readToSingleLong
import org.signal.core.util.requireBlob
import org.signal.core.util.requireBoolean
import org.signal.core.util.requireInt
@ -3625,6 +3626,15 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
}
}
fun getExpiresInSeconds(id: RecipientId): Long {
return readableDatabase
.select(MESSAGE_EXPIRATION_TIME)
.from(TABLE_NAME)
.where(ID_WHERE, id)
.run()
.readToSingleLong(0L)
}
/**
* Will update the database with the content values you specified. It will make an intelligent
* query such that this will only return true if a row was *actually* updated.

View file

@ -54,7 +54,8 @@ class ScheduledMessageManager(
override fun executeEvent(event: Event) {
val scheduledMessagesToSend = messagesTable.getScheduledMessagesBefore(System.currentTimeMillis())
for (record in scheduledMessagesToSend) {
if (messagesTable.clearScheduledStatus(record.threadId, record.id, record.recipient.expiresInSeconds.seconds.inWholeMilliseconds)) {
val expiresIn = SignalDatabase.recipients.getExpiresInSeconds(record.recipient.id)
if (messagesTable.clearScheduledStatus(record.threadId, record.id, expiresIn.seconds.inWholeMilliseconds)) {
if (record.recipient.isPushGroup) {
PushGroupSendJob.enqueue(application, ApplicationDependencies.getJobManager(), record.id, record.recipient.id, emptySet(), true)
} else {