Improve profile fetching

This commit is contained in:
AsamK 2021-12-20 12:26:46 +01:00
parent e7896235a2
commit d21f9cf029

View file

@ -171,7 +171,7 @@ public final class ProfileHelper {
var now = System.currentTimeMillis(); var now = System.currentTimeMillis();
// Profiles are cached for 24h before retrieving them again, unless forced // 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; return profile;
} }
@ -189,11 +189,13 @@ public final class ProfileHelper {
pendingProfileRequest.remove(recipientId); pendingProfileRequest.remove(recipientId);
} }
} }
if (encryptedProfile == null) { 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); account.getProfileStore().storeProfile(recipientId, profile);
return profile; return profile;