Fix scheduled message changing disappearing messages bug.
This commit is contained in:
parent
33ab25a557
commit
6e8f3d1e71
3 changed files with 15 additions and 1 deletions
3
.idea/codeStyles/Project.xml
generated
3
.idea/codeStyles/Project.xml
generated
|
@ -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>
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue