]> nmode's Git Repositories - signal-cli/commitdiff
Send and handle fetch profile sync message
authorAsamK <asamk@gmx.de>
Sun, 17 Jan 2021 16:38:33 +0000 (17:38 +0100)
committerAsamK <asamk@gmx.de>
Sun, 17 Jan 2021 16:38:33 +0000 (17:38 +0100)
src/main/java/org/asamk/signal/manager/Manager.java

index ec427ce39ecfa8dea405581ce1200163d7dfa09d..457a6e543eac6343fb8051b8c374a08c3e036f5c 100644 (file)
@@ -363,6 +363,11 @@ public class Manager implements Closeable {
                 avatarStore.deleteProfileAvatar(getSelfAddress());
             }
         }
                 avatarStore.deleteProfileAvatar(getSelfAddress());
             }
         }
+
+        try {
+            sendSyncMessage(SignalServiceSyncMessage.forFetchLatest(SignalServiceSyncMessage.FetchType.LOCAL_PROFILE));
+        } catch (UntrustedIdentityException ignored) {
+        }
     }
 
     public void unregister() throws IOException {
     }
 
     public void unregister() throws IOException {
@@ -493,6 +498,12 @@ public class Manager implements Closeable {
 
     private SignalProfile getRecipientProfile(
             SignalServiceAddress address
 
     private SignalProfile getRecipientProfile(
             SignalServiceAddress address
+    ) {
+        return getRecipientProfile(address, false);
+    }
+
+    private SignalProfile getRecipientProfile(
+            SignalServiceAddress address, boolean force
     ) {
         SignalProfileEntry profileEntry = account.getProfileStore().getProfileEntry(address);
         if (profileEntry == null) {
     ) {
         SignalProfileEntry profileEntry = account.getProfileStore().getProfileEntry(address);
         if (profileEntry == null) {
@@ -501,7 +512,9 @@ public class Manager implements Closeable {
         long now = new Date().getTime();
         // Profiles are cached for 24h before retrieving them again
         if (!profileEntry.isRequestPending() && (
         long now = new Date().getTime();
         // Profiles are cached for 24h before retrieving them again
         if (!profileEntry.isRequestPending() && (
-                profileEntry.getProfile() == null || now - profileEntry.getLastUpdateTimestamp() > 24 * 60 * 60 * 1000
+                force
+                        || profileEntry.getProfile() == null
+                        || now - profileEntry.getLastUpdateTimestamp() > 24 * 60 * 60 * 1000
         )) {
             profileEntry.setRequestPending(true);
             final SignalServiceProfile encryptedProfile;
         )) {
             profileEntry.setRequestPending(true);
             final SignalServiceProfile encryptedProfile;
@@ -1992,6 +2005,14 @@ public class Manager implements Closeable {
                         account.getStickerStore().updateSticker(sticker);
                     }
                 }
                         account.getStickerStore().updateSticker(sticker);
                     }
                 }
+                if (syncMessage.getFetchType().isPresent()) {
+                    switch (syncMessage.getFetchType().get()) {
+                        case LOCAL_PROFILE:
+                            getRecipientProfile(getSelfAddress(), true);
+                        case STORAGE_MANIFEST:
+                            // TODO
+                    }
+                }
                 if (syncMessage.getConfiguration().isPresent()) {
                     // TODO
                 }
                 if (syncMessage.getConfiguration().isPresent()) {
                     // TODO
                 }