Add backup subscriber fields to account record.

This commit is contained in:
Alex Hart
2024-10-10 16:18:29 -03:00
committed by Greyson Parrelli
parent 497cec4c17
commit 340bb93653
4 changed files with 41 additions and 5 deletions

View File

@@ -94,6 +94,14 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
subscriber = local.getSubscriber();
}
SignalAccountRecord.Subscriber backupsSubscriber;
if (remote.getSubscriber().getId().isPresent()) {
backupsSubscriber = remote.getSubscriber();
} else {
backupsSubscriber = local.getSubscriber();
}
OptionalBool storyViewReceiptsState;
if (remote.getStoryViewReceiptsState() == OptionalBool.UNSET) {
storyViewReceiptsState = local.getStoryViewReceiptsState();
@@ -128,8 +136,8 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
boolean hasSeenUsernameOnboarding = remote.hasCompletedUsernameOnboarding() || local.hasCompletedUsernameOnboarding();
String username = remote.getUsername();
AccountRecord.UsernameLink usernameLink = remote.getUsernameLink();
boolean matchesRemote = doParamsMatch(remote, unknownFields, givenName, familyName, avatarUrlPath, profileKey, noteToSelfArchived, noteToSelfForcedUnread, readReceipts, typingIndicators, sealedSenderIndicators, linkPreviews, phoneNumberSharingMode, unlisted, pinnedConversations, preferContactAvatars, payments, universalExpireTimer, primarySendsSms, e164, defaultReactions, subscriber, displayBadgesOnProfile, subscriptionManuallyCancelled, keepMutedChatsArchived, hasSetMyStoriesPrivacy, hasViewedOnboardingStory, hasSeenUsernameOnboarding, storiesDisabled, storyViewReceiptsState, username, usernameLink);
boolean matchesLocal = doParamsMatch(local, unknownFields, givenName, familyName, avatarUrlPath, profileKey, noteToSelfArchived, noteToSelfForcedUnread, readReceipts, typingIndicators, sealedSenderIndicators, linkPreviews, phoneNumberSharingMode, unlisted, pinnedConversations, preferContactAvatars, payments, universalExpireTimer, primarySendsSms, e164, defaultReactions, subscriber, displayBadgesOnProfile, subscriptionManuallyCancelled, keepMutedChatsArchived, hasSetMyStoriesPrivacy, hasViewedOnboardingStory, hasSeenUsernameOnboarding, storiesDisabled, storyViewReceiptsState, username, usernameLink);
boolean matchesRemote = doParamsMatch(remote, unknownFields, givenName, familyName, avatarUrlPath, profileKey, noteToSelfArchived, noteToSelfForcedUnread, readReceipts, typingIndicators, sealedSenderIndicators, linkPreviews, phoneNumberSharingMode, unlisted, pinnedConversations, preferContactAvatars, payments, universalExpireTimer, primarySendsSms, e164, defaultReactions, subscriber, displayBadgesOnProfile, subscriptionManuallyCancelled, keepMutedChatsArchived, hasSetMyStoriesPrivacy, hasViewedOnboardingStory, hasSeenUsernameOnboarding, storiesDisabled, storyViewReceiptsState, username, usernameLink, backupsSubscriber);
boolean matchesLocal = doParamsMatch(local, unknownFields, givenName, familyName, avatarUrlPath, profileKey, noteToSelfArchived, noteToSelfForcedUnread, readReceipts, typingIndicators, sealedSenderIndicators, linkPreviews, phoneNumberSharingMode, unlisted, pinnedConversations, preferContactAvatars, payments, universalExpireTimer, primarySendsSms, e164, defaultReactions, subscriber, displayBadgesOnProfile, subscriptionManuallyCancelled, keepMutedChatsArchived, hasSetMyStoriesPrivacy, hasViewedOnboardingStory, hasSeenUsernameOnboarding, storiesDisabled, storyViewReceiptsState, username, usernameLink, backupsSubscriber);
if (matchesRemote) {
return remote;
@@ -167,7 +175,8 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
.setHasSeenGroupStoryEducationSheet(hasSeenGroupStoryEducation)
.setHasCompletedUsernameOnboarding(hasSeenUsernameOnboarding)
.setUsername(username)
.setUsernameLink(usernameLink);
.setUsernameLink(usernameLink)
.setBackupsSubscriber(backupsSubscriber);
return builder.build();
}
@@ -219,7 +228,8 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
boolean storiesDisabled,
@NonNull OptionalBool storyViewReceiptsState,
@Nullable String username,
@Nullable AccountRecord.UsernameLink usernameLink)
@Nullable AccountRecord.UsernameLink usernameLink,
@NonNull SignalAccountRecord.Subscriber backupsSubscriber)
{
return Arrays.equals(contact.serializeUnknownFields(), unknownFields) &&
Objects.equals(contact.getGivenName().orElse(""), givenName) &&
@@ -251,6 +261,7 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
contact.isStoriesDisabled() == storiesDisabled &&
contact.getStoryViewReceiptsState().equals(storyViewReceiptsState) &&
Objects.equals(contact.getUsername(), username) &&
Objects.equals(contact.getUsernameLink(), usernameLink);
Objects.equals(contact.getUsernameLink(), usernameLink) &&
Objects.equals(contact.getBackupsSubscriber(), backupsSubscriber);
}
}

View File

@@ -157,6 +157,7 @@ public final class StorageSyncHelper {
.setUniversalExpireTimer(SignalStore.settings().getUniversalExpireTimer())
.setDefaultReactions(SignalStore.emoji().getReactions())
.setSubscriber(StorageSyncModels.localToRemoteSubscriber(InAppPaymentsRepository.getSubscriber(InAppPaymentSubscriberRecord.Type.DONATION)))
.setBackupsSubscriber(StorageSyncModels.localToRemoteSubscriber(InAppPaymentsRepository.getSubscriber(InAppPaymentSubscriberRecord.Type.BACKUP)))
.setDisplayBadgesOnProfile(SignalStore.inAppPayments().getDisplayBadgesOnProfile())
.setSubscriptionManuallyCancelled(InAppPaymentsRepository.isUserManuallyCancelled(InAppPaymentSubscriberRecord.Type.DONATION))
.setKeepMutedChatsArchived(SignalStore.settings().shouldKeepMutedChatsArchived())