mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Improve error handling for profile fetching
This commit is contained in:
parent
6dc8435fa1
commit
7c9839b114
1 changed files with 28 additions and 23 deletions
|
@ -190,33 +190,38 @@ public final class ProfileHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encryptedProfile == null) {
|
Profile newProfile = null;
|
||||||
profile = Profile.newBuilder().withLastUpdateTimestamp(now).build();
|
if (encryptedProfile != null) {
|
||||||
} else {
|
|
||||||
profile = decryptProfileIfKeyKnown(recipientId, encryptedProfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
account.getProfileStore().storeProfile(recipientId, profile);
|
|
||||||
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Profile decryptProfileIfKeyKnown(
|
|
||||||
final RecipientId recipientId, final SignalServiceProfile encryptedProfile
|
|
||||||
) {
|
|
||||||
var profileKey = account.getProfileStore().getProfileKey(recipientId);
|
var profileKey = account.getProfileStore().getProfileKey(recipientId);
|
||||||
if (profileKey == null) {
|
if (profileKey != null) {
|
||||||
return new Profile(System.currentTimeMillis(),
|
newProfile = decryptProfileAndDownloadAvatar(recipientId, profileKey, encryptedProfile);
|
||||||
null,
|
if (newProfile == null) {
|
||||||
null,
|
account.getProfileStore().storeProfileKey(recipientId, null);
|
||||||
null,
|
}
|
||||||
null,
|
|
||||||
null,
|
|
||||||
ProfileUtils.getUnidentifiedAccessMode(encryptedProfile, null),
|
|
||||||
ProfileUtils.getCapabilities(encryptedProfile));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return decryptProfileAndDownloadAvatar(recipientId, profileKey, encryptedProfile);
|
if (newProfile == null) {
|
||||||
|
newProfile = (
|
||||||
|
profile == null ? Profile.newBuilder() : Profile.newBuilder(profile)
|
||||||
|
).withLastUpdateTimestamp(System.currentTimeMillis())
|
||||||
|
.withUnidentifiedAccessMode(ProfileUtils.getUnidentifiedAccessMode(encryptedProfile, null))
|
||||||
|
.withCapabilities(ProfileUtils.getCapabilities(encryptedProfile))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newProfile == null) {
|
||||||
|
newProfile = (
|
||||||
|
profile == null ? Profile.newBuilder() : Profile.newBuilder(profile)
|
||||||
|
).withLastUpdateTimestamp(now)
|
||||||
|
.withUnidentifiedAccessMode(Profile.UnidentifiedAccessMode.UNKNOWN)
|
||||||
|
.withCapabilities(Set.of())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
account.getProfileStore().storeProfile(recipientId, newProfile);
|
||||||
|
|
||||||
|
return newProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SignalServiceProfile retrieveEncryptedProfile(RecipientId recipientId) {
|
private SignalServiceProfile retrieveEncryptedProfile(RecipientId recipientId) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue