mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Fix storage service crash when matching a local contact without an ID.
It's possible that we could match a local contact that doesn't have a storageId, which would crash when we tried to make a model from it for merging. This isn't an impossible case -- it could be that the manifest has record of a user that is newly registered (or just registered at some point and never deleted) and so we need to give our local record a storageId for merging.
This commit is contained in:
@@ -2716,12 +2716,16 @@ public class RecipientDatabase extends Database {
|
||||
ApplicationDependencies.getRecipientCache().clear();
|
||||
}
|
||||
|
||||
public void updateStorageKeys(@NonNull Map<RecipientId, byte[]> keys) {
|
||||
public void updateStorageId(@NonNull RecipientId recipientId, byte[] id) {
|
||||
updateStorageIds(Collections.singletonMap(recipientId, id));
|
||||
}
|
||||
|
||||
public void updateStorageIds(@NonNull Map<RecipientId, byte[]> ids) {
|
||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||
db.beginTransaction();
|
||||
|
||||
try {
|
||||
for (Map.Entry<RecipientId, byte[]> entry : keys.entrySet()) {
|
||||
for (Map.Entry<RecipientId, byte[]> entry : ids.entrySet()) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(STORAGE_SERVICE_ID, Base64.encodeBytes(entry.getValue()));
|
||||
db.update(TABLE_NAME, values, ID_WHERE, new String[] { entry.getKey().serialize() });
|
||||
@@ -2732,7 +2736,7 @@ public class RecipientDatabase extends Database {
|
||||
db.endTransaction();
|
||||
}
|
||||
|
||||
for (RecipientId id : keys.keySet()) {
|
||||
for (RecipientId id : ids.keySet()) {
|
||||
Recipient.live(id).refresh();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user