Use alarm clock for scheduling message sends.

This commit is contained in:
Cody Henthorne
2023-02-06 19:48:11 -05:00
committed by Greyson Parrelli
parent 56b35f3767
commit 3a0dbe6e67
7 changed files with 38 additions and 22 deletions

View File

@@ -4648,16 +4648,20 @@ public class MessageTable extends DatabaseTable implements MessageTypes, Recipie
}
}
public @Nullable Long getOldestScheduledSendTimestamp() {
public @Nullable MessageRecord getOldestScheduledSendTimestamp() {
String[] columns = new String[] { SCHEDULED_DATE };
String selection = STORY_TYPE + " = ? AND " + PARENT_STORY_ID + " <= ? AND " + SCHEDULED_DATE + " != ?";
String[] args = SqlUtil.buildArgs(0, 0, -1);
String order = SCHEDULED_DATE + " ASC, " + ID + " ASC";
String limit = "1";
try (Cursor cursor = getReadableDatabase().query(TABLE_NAME, columns, selection, args, null, null, order, limit)) {
return cursor != null && cursor.moveToNext() ? cursor.getLong(0) : null;
try (MmsReader reader = mmsReaderFor(getReadableDatabase().query(TABLE_NAME, MMS_PROJECTION, selection, args, null, null, order, limit))) {
if (reader.getNext() != null) {
return reader.getCurrent();
}
}
return null;
}
public Cursor getMessagesForNotificationState(Collection<DefaultMessageNotifier.StickyThread> stickyThreads) {