From: AsamK Date: Sat, 31 Jul 2021 15:56:53 +0000 (+0200) Subject: Extract decryptProfileIfKeyKnown helper method X-Git-Tag: v0.8.5~3 X-Git-Url: https://git.nmode.ca/signal-cli/commitdiff_plain/b1ebdc834367657b052764273895bb6ba31a0fb9 Extract decryptProfileIfKeyKnown helper method --- diff --git a/lib/src/main/java/org/asamk/signal/manager/Manager.java b/lib/src/main/java/org/asamk/signal/manager/Manager.java index 37b4aa86..13038bf1 100644 --- a/lib/src/main/java/org/asamk/signal/manager/Manager.java +++ b/lib/src/main/java/org/asamk/signal/manager/Manager.java @@ -618,21 +618,27 @@ public class Manager implements Closeable { return null; } + 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); if (profileKey == null) { - profile = new Profile(System.currentTimeMillis(), + return new Profile(System.currentTimeMillis(), null, null, null, null, ProfileUtils.getUnidentifiedAccessMode(encryptedProfile, null), ProfileUtils.getCapabilities(encryptedProfile)); - } else { - profile = decryptProfileAndDownloadAvatar(recipientId, profileKey, encryptedProfile); } - account.getProfileStore().storeProfile(recipientId, profile); - return profile; + return decryptProfileAndDownloadAvatar(recipientId, profileKey, encryptedProfile); } private SignalServiceProfile retrieveEncryptedProfile(RecipientId recipientId) {