Store the time that a sender key was shared.

fork-5.53.8
Greyson Parrelli 2021-11-01 13:38:04 -04:00
rodzic 3574be913a
commit cef7878b47
2 zmienionych plików z 9 dodań i 1 usunięć

Wyświetl plik

@ -34,11 +34,13 @@ public class SenderKeySharedDatabase extends Database {
public static final String DISTRIBUTION_ID = "distribution_id";
public static final String ADDRESS = "address";
public static final String DEVICE = "device";
public static final String TIMESTAMP = "timestamp";
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + "(" + ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
DISTRIBUTION_ID + " TEXT NOT NULL, " +
ADDRESS + " TEXT NOT NULL, " +
DEVICE + " INTEGER NOT NULL, " +
TIMESTAMP + " INTEGER DEFAULT 0, " +
"UNIQUE(" + DISTRIBUTION_ID + "," + ADDRESS + ", " + DEVICE + ") ON CONFLICT REPLACE);";
SenderKeySharedDatabase(Context context, SQLCipherOpenHelper databaseHelper) {
@ -58,6 +60,7 @@ public class SenderKeySharedDatabase extends Database {
values.put(ADDRESS, address.getName());
values.put(DEVICE, address.getDeviceId());
values.put(DISTRIBUTION_ID, distributionId.toString());
values.put(TIMESTAMP, System.currentTimeMillis());
db.insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
}

Wyświetl plik

@ -218,8 +218,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper implements SignalDatab
private static final int RECEIPT_TIMESTAMP = 117;
private static final int BADGES = 118;
private static final int SENDER_KEY_UUID = 119;
private static final int SENDER_KEY_SHARED_TIMESTAMP = 120;
private static final int DATABASE_VERSION = 119;
private static final int DATABASE_VERSION = 120;
private static final String DATABASE_NAME = "signal.db";
private final Context context;
@ -2075,6 +2076,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper implements SignalDatab
Log.d(TAG, "Sender key migration took " + (System.currentTimeMillis() - start) + " ms");
}
if (oldVersion < SENDER_KEY_SHARED_TIMESTAMP) {
db.execSQL("ALTER TABLE sender_key_shared ADD COLUMN timestamp INTEGER DEFAULT 0");
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();