]> nmode's Git Repositories - signal-cli/commitdiff
Extract decryptProfileIfKeyKnown helper method
authorAsamK <asamk@gmx.de>
Sat, 31 Jul 2021 15:56:53 +0000 (17:56 +0200)
committerAsamK <asamk@gmx.de>
Sat, 31 Jul 2021 20:19:31 +0000 (22:19 +0200)
lib/src/main/java/org/asamk/signal/manager/Manager.java

index 37b4aa860e6ead15b1562923bc9ca323acf76276..13038bf18790d2691c5d7825837266dd4573388d 100644 (file)
@@ -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) {