mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Clear unidentified access mode when profile key changes.
This commit is contained in:
committed by
Greyson Parrelli
parent
455974cb05
commit
23e55ac5f7
@@ -799,25 +799,30 @@ public class RecipientDatabase extends Database {
|
||||
/**
|
||||
* Updates the profile key.
|
||||
* <p>
|
||||
* If it changes, it clears out the profile key credential.
|
||||
* If it changes, it clears out the profile key credential and resets the unidentified access mode.
|
||||
* @return true iff changed.
|
||||
*/
|
||||
public void setProfileKey(@NonNull RecipientId id, @Nullable ProfileKey profileKey) {
|
||||
public boolean setProfileKey(@NonNull RecipientId id, @NonNull ProfileKey profileKey) {
|
||||
String selection = ID + " = ?";
|
||||
String[] args = new String[]{id.serialize()};
|
||||
ContentValues valuesToCompare = new ContentValues(1);
|
||||
ContentValues valuesToSet = new ContentValues(2);
|
||||
String encodedProfileKey = profileKey == null ? null : Base64.encodeBytes(profileKey.serialize());
|
||||
ContentValues valuesToSet = new ContentValues(3);
|
||||
String encodedProfileKey = Base64.encodeBytes(profileKey.serialize());
|
||||
|
||||
valuesToCompare.put(PROFILE_KEY, encodedProfileKey);
|
||||
|
||||
valuesToSet.put(PROFILE_KEY, encodedProfileKey);
|
||||
valuesToSet.putNull(PROFILE_KEY_CREDENTIAL);
|
||||
valuesToSet.put(UNIDENTIFIED_ACCESS_MODE, UnidentifiedAccessMode.UNKNOWN.getMode());
|
||||
|
||||
SqlUtil.UpdateQuery updateQuery = SqlUtil.buildTrueUpdateQuery(selection, args, valuesToCompare);
|
||||
|
||||
if (update(updateQuery, valuesToSet)) {
|
||||
markDirty(id, DirtyState.UPDATE);
|
||||
Recipient.live(id).refresh();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user