mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-03 15:13:50 +00:00
Prevent SendJobs from sending already-sent messages.
This is to guard against behavior WorkManager has where it may re-enqueue a job that has already been completed (if, for instance, it was preempted). Fixes #8268
This commit is contained in:
@@ -1053,6 +1053,17 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSent(long messageId) {
|
||||
SQLiteDatabase database = databaseHelper.getReadableDatabase();
|
||||
try (Cursor cursor = database.query(TABLE_NAME, new String[] { MESSAGE_BOX }, ID + " = ?", new String[] { String.valueOf(messageId)}, null, null, null)) {
|
||||
if (cursor != null && cursor.moveToNext()) {
|
||||
long type = cursor.getLong(cursor.getColumnIndexOrThrow(MESSAGE_BOX));
|
||||
return Types.isSentType(type);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*package*/ void deleteThreads(Set<Long> threadIds) {
|
||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||
String where = "";
|
||||
|
||||
@@ -117,6 +117,10 @@ public interface MmsSmsColumns {
|
||||
(type & BASE_TYPE_MASK) == BASE_SENDING_TYPE;
|
||||
}
|
||||
|
||||
public static boolean isSentType(long type) {
|
||||
return (type & BASE_TYPE_MASK) == BASE_SENT_TYPE;
|
||||
}
|
||||
|
||||
public static boolean isPendingSmsFallbackType(long type) {
|
||||
return (type & BASE_TYPE_MASK) == BASE_PENDING_INSECURE_SMS_FALLBACK ||
|
||||
(type & BASE_TYPE_MASK) == BASE_PENDING_SECURE_SMS_FALLBACK;
|
||||
|
||||
Reference in New Issue
Block a user