Improve retrieval from the identity table.

fork-5.53.8
Greyson Parrelli 2021-08-24 15:15:41 -04:00 zatwierdzone przez Alex Hart
rodzic eb48ab1784
commit 3c4e3cf048
2 zmienionych plików z 28 dodań i 1 usunięć

Wyświetl plik

@ -147,6 +147,21 @@ public class IdentityDatabase extends Database {
firstUse,
timestamp,
nonblockingApproval);
} else if (addressName.charAt(0) != '+') {
if (DatabaseFactory.getRecipientDatabase(context).containsPhoneOrUuid(addressName)) {
Recipient recipient = Recipient.external(context, addressName);
if (recipient.hasE164()) {
Log.i(TAG, "Could not find identity for UUID. Attempting E164.");
return getIdentityStoreRecord(recipient.requireE164());
} else {
Log.i(TAG, "Could not find identity for UUID, and our recipient doesn't have an E164.");
}
} else {
Log.i(TAG, "Could not find identity for UUID, and we don't have a recipient.");
}
} else {
Log.i(TAG, "Could not find identity for E164 either.");
}
} catch (InvalidKeyException | IOException e) {
throw new AssertionError(e);

Wyświetl plik

@ -214,8 +214,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper implements SignalDatab
private static final int SESSION_MIGRATION = 113;
private static final int IDENTITY_MIGRATION = 114;
private static final int GROUP_CALL_RING_TABLE = 115;
private static final int CLEANUP_SESSION_MIGRATION = 116;
private static final int DATABASE_VERSION = 115;
private static final int DATABASE_VERSION = 116;
private static final String DATABASE_NAME = "signal.db";
private final Context context;
@ -2025,6 +2026,17 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper implements SignalDatab
db.execSQL("CREATE INDEX date_received_index on group_call_ring (date_received)");
}
if (oldVersion < CLEANUP_SESSION_MIGRATION) {
int sessionCount = db.delete("sessions", "address LIKE '+%'", null);
Log.i(TAG, "Cleaned up " + sessionCount + " sessions.");
ContentValues storageValues = new ContentValues();
storageValues.putNull("storage_service_key");
int storageCount = db.update("recipient", storageValues, "storage_service_key NOT NULL AND group_id IS NULL AND uuid IS NULL", null);
Log.i(TAG, "Cleaned up " + storageCount + " storageIds.");
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();