]> nmode's Git Repositories - signal-cli/commitdiff
Improve profile fetching
authorAsamK <asamk@gmx.de>
Mon, 20 Dec 2021 11:26:46 +0000 (12:26 +0100)
committerAsamK <asamk@gmx.de>
Mon, 20 Dec 2021 13:04:07 +0000 (14:04 +0100)
lib/src/main/java/org/asamk/signal/manager/helper/ProfileHelper.java

index 5314fe77ba3aa1c5e2a3fba04e60e89183dc5ad9..bf788598057bf4c4045e0ee47d52d15fc3443764 100644 (file)
@@ -171,7 +171,7 @@ public final class ProfileHelper {
 
         var now = System.currentTimeMillis();
         // Profiles are cached for 24h before retrieving them again, unless forced
-        if (!force && profile != null && now - profile.getLastUpdateTimestamp() < 24 * 60 * 60 * 1000) {
+        if (!force && profile != null && now - profile.getLastUpdateTimestamp() < 6 * 60 * 60 * 1000) {
             return profile;
         }
 
@@ -189,11 +189,13 @@ public final class ProfileHelper {
                 pendingProfileRequest.remove(recipientId);
             }
         }
+
         if (encryptedProfile == null) {
-            return null;
+            profile = Profile.newBuilder().withLastUpdateTimestamp(now).build();
+        } else {
+            profile = decryptProfileIfKeyKnown(recipientId, encryptedProfile);
         }
 
-        profile = decryptProfileIfKeyKnown(recipientId, encryptedProfile);
         account.getProfileStore().storeProfile(recipientId, profile);
 
         return profile;