Skip to content

Commit

Permalink
Fix scheduled message changing disappearing messages bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
cody-signal committed Mar 6, 2023
1 parent 33ab25a commit 6e8f3d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Expand Up @@ -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 {
Expand Down

0 comments on commit 6e8f3d1

Please sign in to comment.