mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 03:58:48 +00:00
Add backup subscriber fields to account record.
This commit is contained in:
committed by
Greyson Parrelli
parent
497cec4c17
commit
340bb93653
@@ -94,6 +94,14 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||||||
subscriber = local.getSubscriber();
|
subscriber = local.getSubscriber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SignalAccountRecord.Subscriber backupsSubscriber;
|
||||||
|
|
||||||
|
if (remote.getSubscriber().getId().isPresent()) {
|
||||||
|
backupsSubscriber = remote.getSubscriber();
|
||||||
|
} else {
|
||||||
|
backupsSubscriber = local.getSubscriber();
|
||||||
|
}
|
||||||
|
|
||||||
OptionalBool storyViewReceiptsState;
|
OptionalBool storyViewReceiptsState;
|
||||||
if (remote.getStoryViewReceiptsState() == OptionalBool.UNSET) {
|
if (remote.getStoryViewReceiptsState() == OptionalBool.UNSET) {
|
||||||
storyViewReceiptsState = local.getStoryViewReceiptsState();
|
storyViewReceiptsState = local.getStoryViewReceiptsState();
|
||||||
@@ -128,8 +136,8 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||||||
boolean hasSeenUsernameOnboarding = remote.hasCompletedUsernameOnboarding() || local.hasCompletedUsernameOnboarding();
|
boolean hasSeenUsernameOnboarding = remote.hasCompletedUsernameOnboarding() || local.hasCompletedUsernameOnboarding();
|
||||||
String username = remote.getUsername();
|
String username = remote.getUsername();
|
||||||
AccountRecord.UsernameLink usernameLink = remote.getUsernameLink();
|
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 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);
|
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) {
|
if (matchesRemote) {
|
||||||
return remote;
|
return remote;
|
||||||
@@ -167,7 +175,8 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||||||
.setHasSeenGroupStoryEducationSheet(hasSeenGroupStoryEducation)
|
.setHasSeenGroupStoryEducationSheet(hasSeenGroupStoryEducation)
|
||||||
.setHasCompletedUsernameOnboarding(hasSeenUsernameOnboarding)
|
.setHasCompletedUsernameOnboarding(hasSeenUsernameOnboarding)
|
||||||
.setUsername(username)
|
.setUsername(username)
|
||||||
.setUsernameLink(usernameLink);
|
.setUsernameLink(usernameLink)
|
||||||
|
.setBackupsSubscriber(backupsSubscriber);
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
@@ -219,7 +228,8 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||||||
boolean storiesDisabled,
|
boolean storiesDisabled,
|
||||||
@NonNull OptionalBool storyViewReceiptsState,
|
@NonNull OptionalBool storyViewReceiptsState,
|
||||||
@Nullable String username,
|
@Nullable String username,
|
||||||
@Nullable AccountRecord.UsernameLink usernameLink)
|
@Nullable AccountRecord.UsernameLink usernameLink,
|
||||||
|
@NonNull SignalAccountRecord.Subscriber backupsSubscriber)
|
||||||
{
|
{
|
||||||
return Arrays.equals(contact.serializeUnknownFields(), unknownFields) &&
|
return Arrays.equals(contact.serializeUnknownFields(), unknownFields) &&
|
||||||
Objects.equals(contact.getGivenName().orElse(""), givenName) &&
|
Objects.equals(contact.getGivenName().orElse(""), givenName) &&
|
||||||
@@ -251,6 +261,7 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||||||
contact.isStoriesDisabled() == storiesDisabled &&
|
contact.isStoriesDisabled() == storiesDisabled &&
|
||||||
contact.getStoryViewReceiptsState().equals(storyViewReceiptsState) &&
|
contact.getStoryViewReceiptsState().equals(storyViewReceiptsState) &&
|
||||||
Objects.equals(contact.getUsername(), username) &&
|
Objects.equals(contact.getUsername(), username) &&
|
||||||
Objects.equals(contact.getUsernameLink(), usernameLink);
|
Objects.equals(contact.getUsernameLink(), usernameLink) &&
|
||||||
|
Objects.equals(contact.getBackupsSubscriber(), backupsSubscriber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ public final class StorageSyncHelper {
|
|||||||
.setUniversalExpireTimer(SignalStore.settings().getUniversalExpireTimer())
|
.setUniversalExpireTimer(SignalStore.settings().getUniversalExpireTimer())
|
||||||
.setDefaultReactions(SignalStore.emoji().getReactions())
|
.setDefaultReactions(SignalStore.emoji().getReactions())
|
||||||
.setSubscriber(StorageSyncModels.localToRemoteSubscriber(InAppPaymentsRepository.getSubscriber(InAppPaymentSubscriberRecord.Type.DONATION)))
|
.setSubscriber(StorageSyncModels.localToRemoteSubscriber(InAppPaymentsRepository.getSubscriber(InAppPaymentSubscriberRecord.Type.DONATION)))
|
||||||
|
.setBackupsSubscriber(StorageSyncModels.localToRemoteSubscriber(InAppPaymentsRepository.getSubscriber(InAppPaymentSubscriberRecord.Type.BACKUP)))
|
||||||
.setDisplayBadgesOnProfile(SignalStore.inAppPayments().getDisplayBadgesOnProfile())
|
.setDisplayBadgesOnProfile(SignalStore.inAppPayments().getDisplayBadgesOnProfile())
|
||||||
.setSubscriptionManuallyCancelled(InAppPaymentsRepository.isUserManuallyCancelled(InAppPaymentSubscriberRecord.Type.DONATION))
|
.setSubscriptionManuallyCancelled(InAppPaymentsRepository.isUserManuallyCancelled(InAppPaymentSubscriberRecord.Type.DONATION))
|
||||||
.setKeepMutedChatsArchived(SignalStore.settings().shouldKeepMutedChatsArchived())
|
.setKeepMutedChatsArchived(SignalStore.settings().shouldKeepMutedChatsArchived())
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public final class SignalAccountRecord implements SignalRecord {
|
|||||||
private final Payments payments;
|
private final Payments payments;
|
||||||
private final List<String> defaultReactions;
|
private final List<String> defaultReactions;
|
||||||
private final Subscriber subscriber;
|
private final Subscriber subscriber;
|
||||||
|
private final Subscriber backupsSubscriber;
|
||||||
|
|
||||||
public SignalAccountRecord(StorageId id, AccountRecord proto) {
|
public SignalAccountRecord(StorageId id, AccountRecord proto) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@@ -51,6 +52,7 @@ public final class SignalAccountRecord implements SignalRecord {
|
|||||||
this.pinnedConversations = new ArrayList<>(proto.pinnedConversations.size());
|
this.pinnedConversations = new ArrayList<>(proto.pinnedConversations.size());
|
||||||
this.defaultReactions = new ArrayList<>(proto.preferredReactionEmoji);
|
this.defaultReactions = new ArrayList<>(proto.preferredReactionEmoji);
|
||||||
this.subscriber = new Subscriber(proto.subscriberCurrencyCode, proto.subscriberId.toByteArray());
|
this.subscriber = new Subscriber(proto.subscriberCurrencyCode, proto.subscriberId.toByteArray());
|
||||||
|
this.backupsSubscriber = new Subscriber(proto.backupsSubscriberCurrencyCode, proto.backupsSubscriberId.toByteArray());
|
||||||
|
|
||||||
if (proto.payments != null) {
|
if (proto.payments != null) {
|
||||||
this.payments = new Payments(proto.payments.enabled, OptionalUtil.absentIfEmpty(proto.payments.entropy));
|
this.payments = new Payments(proto.payments.enabled, OptionalUtil.absentIfEmpty(proto.payments.entropy));
|
||||||
@@ -207,6 +209,10 @@ public final class SignalAccountRecord implements SignalRecord {
|
|||||||
diff.add("HasCompletedUsernameOnboarding");
|
diff.add("HasCompletedUsernameOnboarding");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Objects.equals(this.getBackupsSubscriber(), that.getBackupsSubscriber())) {
|
||||||
|
diff.add("BackupsSubscriber");
|
||||||
|
}
|
||||||
|
|
||||||
return diff.toString();
|
return diff.toString();
|
||||||
} else {
|
} else {
|
||||||
return "Different class. " + getClass().getSimpleName() + " | " + other.getClass().getSimpleName();
|
return "Different class. " + getClass().getSimpleName() + " | " + other.getClass().getSimpleName();
|
||||||
@@ -301,6 +307,10 @@ public final class SignalAccountRecord implements SignalRecord {
|
|||||||
return subscriber;
|
return subscriber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Subscriber getBackupsSubscriber() {
|
||||||
|
return backupsSubscriber;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isDisplayBadgesOnProfile() {
|
public boolean isDisplayBadgesOnProfile() {
|
||||||
return proto.displayBadgesOnProfile;
|
return proto.displayBadgesOnProfile;
|
||||||
}
|
}
|
||||||
@@ -666,6 +676,18 @@ public final class SignalAccountRecord implements SignalRecord {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder setBackupsSubscriber(Subscriber subscriber) {
|
||||||
|
if (subscriber.id.isPresent() && subscriber.currencyCode.isPresent()) {
|
||||||
|
builder.backupsSubscriberId(ByteString.of(subscriber.id.get()));
|
||||||
|
builder.backupsSubscriberCurrencyCode(subscriber.currencyCode.get());
|
||||||
|
} else {
|
||||||
|
builder.backupsSubscriberId(StorageRecordProtoUtil.getDefaultAccountRecord().subscriberId);
|
||||||
|
builder.backupsSubscriberCurrencyCode(StorageRecordProtoUtil.getDefaultAccountRecord().subscriberCurrencyCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder setDisplayBadgesOnProfile(boolean displayBadgesOnProfile) {
|
public Builder setDisplayBadgesOnProfile(boolean displayBadgesOnProfile) {
|
||||||
builder.displayBadgesOnProfile(displayBadgesOnProfile);
|
builder.displayBadgesOnProfile(displayBadgesOnProfile);
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -219,6 +219,8 @@ message AccountRecord {
|
|||||||
string username = 33;
|
string username = 33;
|
||||||
bool hasCompletedUsernameOnboarding = 34;
|
bool hasCompletedUsernameOnboarding = 34;
|
||||||
UsernameLink usernameLink = 35;
|
UsernameLink usernameLink = 35;
|
||||||
|
bytes backupsSubscriberId = 36;
|
||||||
|
string backupsSubscriberCurrencyCode = 37;
|
||||||
}
|
}
|
||||||
|
|
||||||
message StoryDistributionListRecord {
|
message StoryDistributionListRecord {
|
||||||
|
|||||||
Reference in New Issue
Block a user