From d21f9cf02909174bf057e89d074a182ec61b45e5 Mon Sep 17 00:00:00 2001 From: AsamK Date: Mon, 20 Dec 2021 12:26:46 +0100 Subject: [PATCH] Improve profile fetching --- .../org/asamk/signal/manager/helper/ProfileHelper.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/src/main/java/org/asamk/signal/manager/helper/ProfileHelper.java b/lib/src/main/java/org/asamk/signal/manager/helper/ProfileHelper.java index 5314fe77..bf788598 100644 --- a/lib/src/main/java/org/asamk/signal/manager/helper/ProfileHelper.java +++ b/lib/src/main/java/org/asamk/signal/manager/helper/ProfileHelper.java @@ -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;