mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-30 23:16:13 +00:00
Support for disappearing messages
// FREEBIE
This commit is contained in:
@@ -67,6 +67,7 @@ public class ThreadDatabase extends Database {
|
||||
public static final String ARCHIVED = "archived";
|
||||
public static final String STATUS = "status";
|
||||
public static final String RECEIPT_COUNT = "delivery_receipt_count";
|
||||
private static final String EXPIRES_IN = "expires_in";
|
||||
|
||||
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" +
|
||||
ID + " INTEGER PRIMARY KEY, " + DATE + " INTEGER DEFAULT 0, " +
|
||||
@@ -75,7 +76,7 @@ public class ThreadDatabase extends Database {
|
||||
TYPE + " INTEGER DEFAULT 0, " + ERROR + " INTEGER DEFAULT 0, " +
|
||||
SNIPPET_TYPE + " INTEGER DEFAULT 0, " + SNIPPET_URI + " TEXT DEFAULT NULL, " +
|
||||
ARCHIVED + " INTEGER DEFAULT 0, " + STATUS + " INTEGER DEFAULT 0, " +
|
||||
RECEIPT_COUNT + " INTEGER DEFAULT 0);";
|
||||
RECEIPT_COUNT + " INTEGER DEFAULT 0, " + EXPIRES_IN + " INTEGER DEFAULT 0);";
|
||||
|
||||
public static final String[] CREATE_INDEXS = {
|
||||
"CREATE INDEX IF NOT EXISTS thread_recipient_ids_index ON " + TABLE_NAME + " (" + RECIPIENT_IDS + ");",
|
||||
@@ -133,7 +134,8 @@ public class ThreadDatabase extends Database {
|
||||
}
|
||||
|
||||
private void updateThread(long threadId, long count, String body, @Nullable Uri attachment,
|
||||
long date, int status, int receiptCount, long type, boolean unarchive)
|
||||
long date, int status, int receiptCount, long type, boolean unarchive,
|
||||
long expiresIn)
|
||||
{
|
||||
ContentValues contentValues = new ContentValues(7);
|
||||
contentValues.put(DATE, date - date % 1000);
|
||||
@@ -143,6 +145,7 @@ public class ThreadDatabase extends Database {
|
||||
contentValues.put(SNIPPET_TYPE, type);
|
||||
contentValues.put(STATUS, status);
|
||||
contentValues.put(RECEIPT_COUNT, receiptCount);
|
||||
contentValues.put(EXPIRES_IN, expiresIn);
|
||||
|
||||
if (unarchive) {
|
||||
contentValues.put(ARCHIVED, 0);
|
||||
@@ -503,7 +506,7 @@ public class ThreadDatabase extends Database {
|
||||
if (reader != null && (record = reader.getNext()) != null) {
|
||||
updateThread(threadId, count, record.getBody().getBody(), getAttachmentUriFor(record),
|
||||
record.getTimestamp(), record.getDeliveryStatus(), record.getReceiptCount(),
|
||||
record.getType(), unarchive);
|
||||
record.getType(), unarchive, record.getExpiresIn());
|
||||
notifyConversationListListeners();
|
||||
return false;
|
||||
} else {
|
||||
@@ -572,10 +575,12 @@ public class ThreadDatabase extends Database {
|
||||
boolean archived = cursor.getInt(cursor.getColumnIndex(ThreadDatabase.ARCHIVED)) != 0;
|
||||
int status = cursor.getInt(cursor.getColumnIndexOrThrow(ThreadDatabase.STATUS));
|
||||
int receiptCount = cursor.getInt(cursor.getColumnIndexOrThrow(ThreadDatabase.RECEIPT_COUNT));
|
||||
long expiresIn = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.EXPIRES_IN));
|
||||
Uri snippetUri = getSnippetUri(cursor);
|
||||
|
||||
return new ThreadRecord(context, body, snippetUri, recipients, date, count, read == 1,
|
||||
threadId, receiptCount, status, type, distributionType, archived);
|
||||
threadId, receiptCount, status, type, distributionType, archived,
|
||||
expiresIn);
|
||||
}
|
||||
|
||||
private DisplayRecord.Body getPlaintextBody(Cursor cursor) {
|
||||
|
||||
Reference in New Issue
Block a user