]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/Manager.java
Only send plain text pin if locked with registration lock v1
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / Manager.java
index 4abe1260383d9046d7515e8f6e20210e2ccf7a0a..c619acbc7864e121d377c6d5b5f9a726e3482d72 100644 (file)
@@ -556,14 +556,6 @@ public class Manager implements Closeable {
     Profile getRecipientProfile(
             RecipientId recipientId, boolean force
     ) {
-        var profileKey = account.getProfileStore().getProfileKey(recipientId);
-        if (profileKey == null) {
-            if (force) {
-                // retrieve profile to get identity key
-                retrieveEncryptedProfile(recipientId);
-            }
-            return null;
-        }
         var profile = account.getProfileStore().getProfile(recipientId);
 
         var now = new Date().getTime();
@@ -590,7 +582,18 @@ public class Manager implements Closeable {
             return null;
         }
 
-        profile = decryptProfileAndDownloadAvatar(recipientId, profileKey, encryptedProfile);
+        var profileKey = account.getProfileStore().getProfileKey(recipientId);
+        if (profileKey == null) {
+            profile = new Profile(new Date().getTime(),
+                    null,
+                    null,
+                    null,
+                    null,
+                    ProfileUtils.getUnidentifiedAccessMode(encryptedProfile, null),
+                    ProfileUtils.getCapabilities(encryptedProfile));
+        } else {
+            profile = decryptProfileAndDownloadAvatar(recipientId, profileKey, encryptedProfile);
+        }
         account.getProfileStore().storeProfile(recipientId, profile);
 
         return profile;
@@ -1101,9 +1104,11 @@ public class Manager implements Closeable {
         }
     }
 
-    SendMessageResult renewSession(RecipientId recipientId) throws IOException {
+    void renewSession(RecipientId recipientId) throws IOException {
         account.getSessionStore().archiveSessions(recipientId);
-        return sendNullMessage(recipientId);
+        if (!recipientId.equals(getSelfRecipientId())) {
+            sendNullMessage(recipientId);
+        }
     }
 
     public String getContactName(String number) throws InvalidNumberException {
@@ -1839,6 +1844,7 @@ public class Manager implements Closeable {
 
             if (envelope.hasSource()) {
                 // Store uuid if we don't have it already
+                // address/uuid in envelope is sent by server
                 resolveRecipientTrusted(envelope.getSourceAddress());
             }
             final var notAGroupMember = isNotAGroupMember(envelope, content);
@@ -1848,6 +1854,11 @@ public class Manager implements Closeable {
                 } catch (Exception e) {
                     exception = e;
                 }
+                if (!envelope.hasSource() && content != null) {
+                    // Store uuid if we don't have it already
+                    // address/uuid is validated by unidentified sender certificate
+                    resolveRecipientTrusted(content.getSender());
+                }
                 var actions = handleMessage(envelope, content, ignoreAttachments);
                 if (exception instanceof ProtocolInvalidMessageException) {
                     final var sender = resolveRecipient(((ProtocolInvalidMessageException) exception).getSender());