]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/Manager.java
Add dbus SignalControl interface to register/verify/link accounts
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / Manager.java
index 37b4aa860e6ead15b1562923bc9ca323acf76276..ef0b404b98ef38d0af3b0df770fcf3f0828c61ff 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) {
@@ -2077,7 +2083,7 @@ public class Manager implements Closeable {
 
         var hasCaughtUpWithOldMessages = false;
 
-        while (true) {
+        while (!Thread.interrupted()) {
             SignalServiceEnvelope envelope;
             SignalServiceContent content = null;
             Exception exception = null;