Skip to content

Commit

Permalink
Fix scheduled message sends changing thread disappearing message timer.
Browse files Browse the repository at this point in the history
  • Loading branch information
cody-signal authored and alex-signal committed Feb 6, 2023
1 parent 67fb9d0 commit 7bae8b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1957,12 +1957,13 @@ public void markDownloadState(long messageId, long state) {
ApplicationDependencies.getDatabaseObserver().notifyMessageUpdateObservers(new MessageId(messageId));
}

public boolean clearScheduledStatus(long threadId, long messageId) {
public boolean clearScheduledStatus(long threadId, long messageId, long expiresIn) {
SQLiteDatabase database = databaseHelper.getSignalWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(SCHEDULED_DATE, -1);
contentValues.put(DATE_SENT, System.currentTimeMillis());
contentValues.put(DATE_RECEIVED, System.currentTimeMillis());
contentValues.put(EXPIRES_IN, expiresIn);

int rowsUpdated = database.update(TABLE_NAME, contentValues, ID_WHERE + " AND " + SCHEDULED_DATE + "!= ?", SqlUtil.buildArgs(messageId, -1));
ApplicationDependencies.getDatabaseObserver().notifyMessageInsertObservers(threadId, new MessageId(messageId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.thoughtcrime.securesms.database.SignalDatabase
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.jobs.IndividualSendJob
import org.thoughtcrime.securesms.jobs.PushGroupSendJob
import kotlin.time.Duration.Companion.seconds

/**
* Manages waking up and sending scheduled messages at the correct time
Expand Down Expand Up @@ -43,7 +44,7 @@ class ScheduledMessageManager(
override fun executeEvent(event: Event) {
val scheduledMessagesToSend = messagesTable.getScheduledMessagesBefore(System.currentTimeMillis())
for (record in scheduledMessagesToSend) {
if (SignalDatabase.messages.clearScheduledStatus(record.threadId, record.id)) {
if (messagesTable.clearScheduledStatus(record.threadId, record.id, record.recipient.expiresInSeconds.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 7bae8b6

Please sign in to comment.