mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 07:48:34 +00:00
Don't allow account record updates to delete our profile key.
This commit is contained in:
parent
c4ec0c9897
commit
f70e41e7cd
@ -648,13 +648,18 @@ public class RecipientDatabase extends Database {
|
|||||||
public void applyStorageSyncUpdates(@NonNull StorageId storageId, SignalAccountRecord update) {
|
public void applyStorageSyncUpdates(@NonNull StorageId storageId, SignalAccountRecord update) {
|
||||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||||
|
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
ProfileName profileName = ProfileName.fromParts(update.getGivenName().orNull(), update.getFamilyName().orNull());
|
ProfileName profileName = ProfileName.fromParts(update.getGivenName().orNull(), update.getFamilyName().orNull());
|
||||||
|
String profileKey = update.getProfileKey().or(Optional.fromNullable(Recipient.self().getProfileKey())).transform(Base64::encodeBytes).orNull();
|
||||||
|
|
||||||
|
if (!update.getProfileKey().isPresent()) {
|
||||||
|
Log.w(TAG, "Got an empty profile key while applying an account record update!");
|
||||||
|
}
|
||||||
|
|
||||||
values.put(PROFILE_GIVEN_NAME, profileName.getGivenName());
|
values.put(PROFILE_GIVEN_NAME, profileName.getGivenName());
|
||||||
values.put(PROFILE_FAMILY_NAME, profileName.getFamilyName());
|
values.put(PROFILE_FAMILY_NAME, profileName.getFamilyName());
|
||||||
values.put(PROFILE_JOINED_NAME, profileName.toString());
|
values.put(PROFILE_JOINED_NAME, profileName.toString());
|
||||||
values.put(PROFILE_KEY, update.getProfileKey().transform(Base64::encodeBytes).orNull());
|
values.put(PROFILE_KEY, profileKey);
|
||||||
values.put(STORAGE_SERVICE_ID, Base64.encodeBytes(update.getId().getRaw()));
|
values.put(STORAGE_SERVICE_ID, Base64.encodeBytes(update.getId().getRaw()));
|
||||||
values.put(DIRTY, DirtyState.CLEAN.getId());
|
values.put(DIRTY, DirtyState.CLEAN.getId());
|
||||||
|
|
||||||
|
@ -385,7 +385,6 @@ public final class StorageSyncHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SignalStorageRecord buildAccountRecord(@NonNull Context context, @NonNull Recipient self) {
|
public static SignalStorageRecord buildAccountRecord(@NonNull Context context, @NonNull Recipient self) {
|
||||||
|
|
||||||
SignalAccountRecord account = new SignalAccountRecord.Builder(self.getStorageServiceId())
|
SignalAccountRecord account = new SignalAccountRecord.Builder(self.getStorageServiceId())
|
||||||
.setProfileKey(self.getProfileKey())
|
.setProfileKey(self.getProfileKey())
|
||||||
.setGivenName(self.getProfileName().getGivenName())
|
.setGivenName(self.getProfileName().getGivenName())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user