mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-10 21:28:34 +00:00
Ensure we refresh attributes if key changes from storage service.
This commit is contained in:
parent
5ea132e712
commit
5468f1705c
@ -28,6 +28,7 @@ import org.thoughtcrime.securesms.database.model.ThreadRecord;
|
|||||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||||
import org.thoughtcrime.securesms.groups.GroupId;
|
import org.thoughtcrime.securesms.groups.GroupId;
|
||||||
import org.thoughtcrime.securesms.groups.v2.ProfileKeySet;
|
import org.thoughtcrime.securesms.groups.v2.ProfileKeySet;
|
||||||
|
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob;
|
||||||
import org.thoughtcrime.securesms.jobs.WakeGroupV2Job;
|
import org.thoughtcrime.securesms.jobs.WakeGroupV2Job;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||||
@ -54,6 +55,7 @@ import org.whispersystems.signalservice.api.storage.SignalContactRecord;
|
|||||||
import org.whispersystems.signalservice.api.storage.SignalGroupV1Record;
|
import org.whispersystems.signalservice.api.storage.SignalGroupV1Record;
|
||||||
import org.whispersystems.signalservice.api.storage.SignalGroupV2Record;
|
import org.whispersystems.signalservice.api.storage.SignalGroupV2Record;
|
||||||
import org.whispersystems.signalservice.api.storage.StorageId;
|
import org.whispersystems.signalservice.api.storage.StorageId;
|
||||||
|
import org.whispersystems.signalservice.api.util.OptionalUtil;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
@ -852,9 +854,11 @@ public class RecipientDatabase extends Database {
|
|||||||
|
|
||||||
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();
|
Optional<ProfileKey> localKey = ProfileKeyUtil.profileKeyOptional(Recipient.self().getProfileKey());
|
||||||
|
Optional<ProfileKey> remoteKey = ProfileKeyUtil.profileKeyOptional(update.getProfileKey().orNull());
|
||||||
|
String profileKey = remoteKey.or(localKey).transform(ProfileKey::serialize).transform(Base64::encodeBytes).orNull();
|
||||||
|
|
||||||
if (!update.getProfileKey().isPresent()) {
|
if (!remoteKey.isPresent()) {
|
||||||
Log.w(TAG, "Got an empty profile key while applying an account record update!");
|
Log.w(TAG, "Got an empty profile key while applying an account record update!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -870,6 +874,10 @@ public class RecipientDatabase extends Database {
|
|||||||
throw new AssertionError("Account update didn't match any rows!");
|
throw new AssertionError("Account update didn't match any rows!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!remoteKey.equals(localKey)) {
|
||||||
|
ApplicationDependencies.getJobManager().add(new RefreshAttributesJob());
|
||||||
|
}
|
||||||
|
|
||||||
Recipient.self().live().refresh();
|
Recipient.self().live().refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user