Send and handle fetch profile sync message

This commit is contained in:
AsamK 2021-01-17 17:38:33 +01:00
parent 70690fef36
commit 804ad34a08

View 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( private SignalProfile getRecipientProfile(
SignalServiceAddress address SignalServiceAddress address
) {
return getRecipientProfile(address, false);
}
private SignalProfile getRecipientProfile(
SignalServiceAddress address, boolean force
) { ) {
SignalProfileEntry profileEntry = account.getProfileStore().getProfileEntry(address); SignalProfileEntry profileEntry = account.getProfileStore().getProfileEntry(address);
if (profileEntry == null) { if (profileEntry == null) {
@ -501,7 +512,9 @@ public class Manager implements Closeable {
long now = new Date().getTime(); long now = new Date().getTime();
// Profiles are cached for 24h before retrieving them again // Profiles are cached for 24h before retrieving them again
if (!profileEntry.isRequestPending() && ( 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); profileEntry.setRequestPending(true);
final SignalServiceProfile encryptedProfile; 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()) { if (syncMessage.getConfiguration().isPresent()) {
// TODO // TODO
} }