Remove deprecated storage service fields.

This commit is contained in:
Greyson Parrelli
2023-11-15 16:51:00 -05:00
parent 12f9ac3aa4
commit cf7d5b3481
9 changed files with 9 additions and 93 deletions

View File

@@ -76,7 +76,6 @@ import org.thoughtcrime.securesms.migrations.StickerMyDailyLifeMigrationJob;
import org.thoughtcrime.securesms.migrations.StorageCapabilityMigrationJob; import org.thoughtcrime.securesms.migrations.StorageCapabilityMigrationJob;
import org.thoughtcrime.securesms.migrations.StorageServiceMigrationJob; import org.thoughtcrime.securesms.migrations.StorageServiceMigrationJob;
import org.thoughtcrime.securesms.migrations.StorageServiceSystemNameMigrationJob; import org.thoughtcrime.securesms.migrations.StorageServiceSystemNameMigrationJob;
import org.thoughtcrime.securesms.migrations.StoryReadStateMigrationJob;
import org.thoughtcrime.securesms.migrations.StoryViewedReceiptsStateMigrationJob; import org.thoughtcrime.securesms.migrations.StoryViewedReceiptsStateMigrationJob;
import org.thoughtcrime.securesms.migrations.Svr2MirrorMigrationJob; import org.thoughtcrime.securesms.migrations.Svr2MirrorMigrationJob;
import org.thoughtcrime.securesms.migrations.SyncDistributionListsMigrationJob; import org.thoughtcrime.securesms.migrations.SyncDistributionListsMigrationJob;
@@ -262,7 +261,6 @@ public final class JobManagerFactories {
put(StorageCapabilityMigrationJob.KEY, new StorageCapabilityMigrationJob.Factory()); put(StorageCapabilityMigrationJob.KEY, new StorageCapabilityMigrationJob.Factory());
put(StorageServiceMigrationJob.KEY, new StorageServiceMigrationJob.Factory()); put(StorageServiceMigrationJob.KEY, new StorageServiceMigrationJob.Factory());
put(StorageServiceSystemNameMigrationJob.KEY, new StorageServiceSystemNameMigrationJob.Factory()); put(StorageServiceSystemNameMigrationJob.KEY, new StorageServiceSystemNameMigrationJob.Factory());
put(StoryReadStateMigrationJob.KEY, new StoryReadStateMigrationJob.Factory());
put(StoryViewedReceiptsStateMigrationJob.KEY, new StoryViewedReceiptsStateMigrationJob.Factory()); put(StoryViewedReceiptsStateMigrationJob.KEY, new StoryViewedReceiptsStateMigrationJob.Factory());
put(Svr2MirrorMigrationJob.KEY, new Svr2MirrorMigrationJob.Factory()); put(Svr2MirrorMigrationJob.KEY, new Svr2MirrorMigrationJob.Factory());
put(SyncDistributionListsMigrationJob.KEY, new SyncDistributionListsMigrationJob.Factory()); put(SyncDistributionListsMigrationJob.KEY, new SyncDistributionListsMigrationJob.Factory());
@@ -306,6 +304,7 @@ public final class JobManagerFactories {
put("MmsReceiveJob", new FailingJob.Factory()); put("MmsReceiveJob", new FailingJob.Factory());
put("MmsDownloadJob", new FailingJob.Factory()); put("MmsDownloadJob", new FailingJob.Factory());
put("SmsReceiveJob", new FailingJob.Factory()); put("SmsReceiveJob", new FailingJob.Factory());
put("StoryReadStateMigrationJob", new PassingMigrationJob.Factory());
}}; }};
} }

View File

@@ -40,11 +40,6 @@ internal class StoryValues(store: KeyValueStore) : SignalStoreValues(store) {
*/ */
private const val USER_HAS_VIEWED_ONBOARDING_STORY = "stories.user.has.seen.onboarding" private const val USER_HAS_VIEWED_ONBOARDING_STORY = "stories.user.has.seen.onboarding"
/**
* Marks whether the user has seen the onboarding story in the stories landing page
*/
private const val USER_HAS_READ_ONBOARDING_STORY = "stories.user.has.read.onboarding"
/** /**
* Whether or not the user will send and receive viewed receipts for stories * Whether or not the user will send and receive viewed receipts for stories
*/ */
@@ -66,7 +61,6 @@ internal class StoryValues(store: KeyValueStore) : SignalStoreValues(store) {
USER_HAS_SEEN_FIRST_NAV_VIEW, USER_HAS_SEEN_FIRST_NAV_VIEW,
HAS_DOWNLOADED_ONBOARDING_STORY, HAS_DOWNLOADED_ONBOARDING_STORY,
USER_HAS_VIEWED_ONBOARDING_STORY, USER_HAS_VIEWED_ONBOARDING_STORY,
USER_HAS_READ_ONBOARDING_STORY,
STORY_VIEWED_RECEIPTS, STORY_VIEWED_RECEIPTS,
USER_HAS_SEEN_GROUP_STORY_EDUCATION_SHEET USER_HAS_SEEN_GROUP_STORY_EDUCATION_SHEET
) )
@@ -83,8 +77,6 @@ internal class StoryValues(store: KeyValueStore) : SignalStoreValues(store) {
var userHasViewedOnboardingStory: Boolean by booleanValue(USER_HAS_VIEWED_ONBOARDING_STORY, false) var userHasViewedOnboardingStory: Boolean by booleanValue(USER_HAS_VIEWED_ONBOARDING_STORY, false)
var userHasReadOnboardingStory: Boolean by booleanValue(USER_HAS_READ_ONBOARDING_STORY, false)
var viewedReceiptsEnabled: Boolean by booleanValue(STORY_VIEWED_RECEIPTS, false) var viewedReceiptsEnabled: Boolean by booleanValue(STORY_VIEWED_RECEIPTS, false)
var userHasSeenGroupStoryEducationSheet: Boolean by booleanValue(USER_HAS_SEEN_GROUP_STORY_EDUCATION_SHEET, false) var userHasSeenGroupStoryEducationSheet: Boolean by booleanValue(USER_HAS_SEEN_GROUP_STORY_EDUCATION_SHEET, false)
@@ -93,10 +85,6 @@ internal class StoryValues(store: KeyValueStore) : SignalStoreValues(store) {
return store.containsKey(STORY_VIEWED_RECEIPTS) return store.containsKey(STORY_VIEWED_RECEIPTS)
} }
fun hasUserOnboardingStoryReadBeenSet(): Boolean {
return store.containsKey(USER_HAS_READ_ONBOARDING_STORY)
}
fun setLatestStorySend(storySend: StorySend) { fun setLatestStorySend(storySend: StorySend) {
synchronized(this) { synchronized(this) {
val storySends: List<StorySend> = getList(LATEST_STORY_SENDS, StorySendSerializer) val storySends: List<StorySend> = getList(LATEST_STORY_SENDS, StorySendSerializer)

View File

@@ -110,7 +110,7 @@ public class ApplicationMigrations {
static final int PNI_2 = 66; static final int PNI_2 = 66;
static final int SYSTEM_NAME_SYNC = 67; static final int SYSTEM_NAME_SYNC = 67;
static final int STORY_VIEWED_STATE = 68; static final int STORY_VIEWED_STATE = 68;
static final int STORY_READ_STATE = 69; // static final int STORY_READ_STATE = 69;
static final int THREAD_MESSAGE_SCHEMA_CHANGE = 70; static final int THREAD_MESSAGE_SCHEMA_CHANGE = 70;
static final int SMS_MMS_MERGE = 71; static final int SMS_MMS_MERGE = 71;
static final int REBUILD_MESSAGE_FTS_INDEX = 72; static final int REBUILD_MESSAGE_FTS_INDEX = 72;
@@ -517,9 +517,9 @@ public class ApplicationMigrations {
jobs.put(Version.STORY_VIEWED_STATE, new StoryViewedReceiptsStateMigrationJob()); jobs.put(Version.STORY_VIEWED_STATE, new StoryViewedReceiptsStateMigrationJob());
} }
if (lastSeenVersion < Version.STORY_READ_STATE) { // if (lastSeenVersion < Version.STORY_READ_STATE) {
jobs.put(Version.STORY_READ_STATE, new StoryReadStateMigrationJob()); // jobs.put(Version.STORY_READ_STATE, new StoryReadStateMigrationJob());
} // }
if (lastSeenVersion < Version.THREAD_MESSAGE_SCHEMA_CHANGE) { if (lastSeenVersion < Version.THREAD_MESSAGE_SCHEMA_CHANGE) {
jobs.put(Version.THREAD_MESSAGE_SCHEMA_CHANGE, new DatabaseMigrationJob()); jobs.put(Version.THREAD_MESSAGE_SCHEMA_CHANGE, new DatabaseMigrationJob());

View File

@@ -1,44 +0,0 @@
package org.thoughtcrime.securesms.migrations
import org.thoughtcrime.securesms.database.SignalDatabase
import org.thoughtcrime.securesms.database.SignalDatabase.Companion.recipients
import org.thoughtcrime.securesms.jobmanager.Job
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.storage.StorageSyncHelper
/**
* Added to initialize whether the user has seen the onboarding story
*/
internal class StoryReadStateMigrationJob(
parameters: Parameters = Parameters.Builder().build()
) : MigrationJob(parameters) {
companion object {
const val KEY = "StoryReadStateMigrationJob"
}
override fun getFactoryKey(): String = KEY
override fun isUiBlocking(): Boolean = false
override fun performMigration() {
if (!SignalStore.storyValues().hasUserOnboardingStoryReadBeenSet()) {
SignalStore.storyValues().userHasReadOnboardingStory = SignalStore.storyValues().userHasReadOnboardingStory
SignalDatabase.messages.markOnboardingStoryRead()
if (SignalStore.account().isRegistered) {
recipients.markNeedsSync(Recipient.self().id)
StorageSyncHelper.scheduleSyncForDataChange()
}
}
}
override fun shouldRetry(e: Exception): Boolean = false
class Factory : Job.Factory<StoryReadStateMigrationJob> {
override fun create(parameters: Parameters, serializedData: ByteArray?): StoryReadStateMigrationJob {
return StoryReadStateMigrationJob(parameters)
}
}
}

View File

@@ -124,12 +124,11 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
boolean hasSetMyStoriesPrivacy = remote.hasSetMyStoriesPrivacy(); boolean hasSetMyStoriesPrivacy = remote.hasSetMyStoriesPrivacy();
boolean hasViewedOnboardingStory = remote.hasViewedOnboardingStory() || local.hasViewedOnboardingStory(); boolean hasViewedOnboardingStory = remote.hasViewedOnboardingStory() || local.hasViewedOnboardingStory();
boolean storiesDisabled = remote.isStoriesDisabled(); boolean storiesDisabled = remote.isStoriesDisabled();
boolean hasReadOnboardingStory = remote.hasReadOnboardingStory() || remote.hasViewedOnboardingStory() || local.hasReadOnboardingStory() || local.hasViewedOnboardingStory() ;
boolean hasSeenGroupStoryEducation = remote.hasSeenGroupStoryEducationSheet() || local.hasSeenGroupStoryEducationSheet(); boolean hasSeenGroupStoryEducation = remote.hasSeenGroupStoryEducationSheet() || local.hasSeenGroupStoryEducationSheet();
String username = !StringUtil.isEmpty(remote.getUsername()) ? remote.getUsername() : local.getUsername(); String username = !StringUtil.isEmpty(remote.getUsername()) ? remote.getUsername() : local.getUsername();
AccountRecord.UsernameLink usernameLink = remote.getUsernameLink() != null ? remote.getUsernameLink() : local.getUsernameLink(); AccountRecord.UsernameLink usernameLink = remote.getUsernameLink() != null ? remote.getUsernameLink() : local.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, storiesDisabled, storyViewReceiptsState, hasReadOnboardingStory, 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, 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, storiesDisabled, storyViewReceiptsState, hasReadOnboardingStory, 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, storiesDisabled, storyViewReceiptsState, username, usernameLink);
if (matchesRemote) { if (matchesRemote) {
return remote; return remote;
@@ -163,7 +162,6 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
.setHasSetMyStoriesPrivacy(hasSetMyStoriesPrivacy) .setHasSetMyStoriesPrivacy(hasSetMyStoriesPrivacy)
.setHasViewedOnboardingStory(hasViewedOnboardingStory) .setHasViewedOnboardingStory(hasViewedOnboardingStory)
.setStoriesDisabled(storiesDisabled) .setStoriesDisabled(storiesDisabled)
.setHasReadOnboardingStory(hasReadOnboardingStory)
.setHasSeenGroupStoryEducationSheet(hasSeenGroupStoryEducation) .setHasSeenGroupStoryEducationSheet(hasSeenGroupStoryEducation)
.setUsername(username) .setUsername(username)
.setUsernameLink(usernameLink); .setUsernameLink(usernameLink);
@@ -220,7 +218,6 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
boolean hasViewedOnboardingStory, boolean hasViewedOnboardingStory,
boolean storiesDisabled, boolean storiesDisabled,
@NonNull OptionalBool storyViewReceiptsState, @NonNull OptionalBool storyViewReceiptsState,
boolean hasReadOnboardingStory,
@Nullable String username, @Nullable String username,
@Nullable AccountRecord.UsernameLink usernameLink) @Nullable AccountRecord.UsernameLink usernameLink)
{ {
@@ -252,7 +249,6 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
contact.hasViewedOnboardingStory() == hasViewedOnboardingStory && contact.hasViewedOnboardingStory() == hasViewedOnboardingStory &&
contact.isStoriesDisabled() == storiesDisabled && contact.isStoriesDisabled() == storiesDisabled &&
contact.getStoryViewReceiptsState().equals(storyViewReceiptsState) && contact.getStoryViewReceiptsState().equals(storyViewReceiptsState) &&
contact.hasReadOnboardingStory() == hasReadOnboardingStory &&
Objects.equals(contact.getUsername(), username) && Objects.equals(contact.getUsername(), username) &&
Objects.equals(contact.getUsernameLink(), usernameLink); Objects.equals(contact.getUsernameLink(), usernameLink);
} }

View File

@@ -133,8 +133,6 @@ public final class StorageSyncHelper {
Log.w(TAG, "[buildAccountRecord] StorageId on RecipientRecord did not match self! ID: " + self.getId()); Log.w(TAG, "[buildAccountRecord] StorageId on RecipientRecord did not match self! ID: " + self.getId());
} }
final boolean hasReadOnboardingStory = SignalStore.storyValues().getUserHasViewedOnboardingStory() || SignalStore.storyValues().getUserHasReadOnboardingStory();
byte[] storageId = record != null && record.getStorageId() != null ? record.getStorageId() : self.getStorageServiceId(); byte[] storageId = record != null && record.getStorageId() != null ? record.getStorageId() : self.getStorageServiceId();
SignalAccountRecord.Builder account = new SignalAccountRecord.Builder(storageId, record != null ? record.getSyncExtras().getStorageProto() : null) SignalAccountRecord.Builder account = new SignalAccountRecord.Builder(storageId, record != null ? record.getSyncExtras().getStorageProto() : null)
@@ -164,7 +162,6 @@ public final class StorageSyncHelper {
.setHasViewedOnboardingStory(SignalStore.storyValues().getUserHasViewedOnboardingStory()) .setHasViewedOnboardingStory(SignalStore.storyValues().getUserHasViewedOnboardingStory())
.setStoriesDisabled(SignalStore.storyValues().isFeatureDisabled()) .setStoriesDisabled(SignalStore.storyValues().isFeatureDisabled())
.setStoryViewReceiptsState(storyViewReceiptsState) .setStoryViewReceiptsState(storyViewReceiptsState)
.setHasReadOnboardingStory(hasReadOnboardingStory)
.setHasSeenGroupStoryEducationSheet(SignalStore.storyValues().getUserHasSeenGroupStoryEducationSheet()) .setHasSeenGroupStoryEducationSheet(SignalStore.storyValues().getUserHasSeenGroupStoryEducationSheet())
.setUsername(SignalStore.account().getUsername()); .setUsername(SignalStore.account().getUsername());
@@ -209,7 +206,6 @@ public final class StorageSyncHelper {
SignalStore.storyValues().setUserHasBeenNotifiedAboutStories(update.getNew().hasSetMyStoriesPrivacy()); SignalStore.storyValues().setUserHasBeenNotifiedAboutStories(update.getNew().hasSetMyStoriesPrivacy());
SignalStore.storyValues().setUserHasViewedOnboardingStory(update.getNew().hasViewedOnboardingStory()); SignalStore.storyValues().setUserHasViewedOnboardingStory(update.getNew().hasViewedOnboardingStory());
SignalStore.storyValues().setFeatureDisabled(update.getNew().isStoriesDisabled()); SignalStore.storyValues().setFeatureDisabled(update.getNew().isStoriesDisabled());
SignalStore.storyValues().setUserHasReadOnboardingStory(update.getNew().hasReadOnboardingStory());
SignalStore.storyValues().setUserHasSeenGroupStoryEducationSheet(update.getNew().hasSeenGroupStoryEducationSheet()); SignalStore.storyValues().setUserHasSeenGroupStoryEducationSheet(update.getNew().hasSeenGroupStoryEducationSheet());
SignalStore.account().setUsername(update.getNew().getUsername()); SignalStore.account().setUsername(update.getNew().getUsername());

View File

@@ -21,7 +21,6 @@ import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.recipients.RecipientForeverObserver import org.thoughtcrime.securesms.recipients.RecipientForeverObserver
import org.thoughtcrime.securesms.recipients.RecipientId import org.thoughtcrime.securesms.recipients.RecipientId
import org.thoughtcrime.securesms.sms.MessageSender import org.thoughtcrime.securesms.sms.MessageSender
import org.thoughtcrime.securesms.stories.Stories
class StoriesLandingRepository(context: Context) { class StoriesLandingRepository(context: Context) {
@@ -169,11 +168,6 @@ class StoriesLandingRepository(context: Context) {
val releaseThread: Long? = SignalStore.releaseChannelValues().releaseChannelRecipientId?.let { SignalDatabase.threads.getThreadIdIfExistsFor(it) } val releaseThread: Long? = SignalStore.releaseChannelValues().releaseChannelRecipientId?.let { SignalDatabase.threads.getThreadIdIfExistsFor(it) }
MultiDeviceReadUpdateJob.enqueue(messageInfos.filter { it.threadId == releaseThread }.map { it.syncMessageId }) MultiDeviceReadUpdateJob.enqueue(messageInfos.filter { it.threadId == releaseThread }.map { it.syncMessageId })
if (messageInfos.any { it.threadId == releaseThread }) {
SignalStore.storyValues().userHasReadOnboardingStory = true
Stories.onStorySettingsChanged(Recipient.self().id)
}
} }
} }

View File

@@ -195,10 +195,6 @@ public final class SignalAccountRecord implements SignalRecord {
diff.add("StoryViewedReceipts"); diff.add("StoryViewedReceipts");
} }
if (hasReadOnboardingStory() != that.hasReadOnboardingStory()) {
diff.add("HasReadOnboardingStory");
}
if (hasSeenGroupStoryEducationSheet() != that.hasSeenGroupStoryEducationSheet()) { if (hasSeenGroupStoryEducationSheet() != that.hasSeenGroupStoryEducationSheet()) {
diff.add("HasSeenGroupStoryEducationSheet"); diff.add("HasSeenGroupStoryEducationSheet");
} }
@@ -329,10 +325,6 @@ public final class SignalAccountRecord implements SignalRecord {
return proto.storyViewReceiptsEnabled; return proto.storyViewReceiptsEnabled;
} }
public boolean hasReadOnboardingStory() {
return proto.hasReadOnboardingStory;
}
public boolean hasSeenGroupStoryEducationSheet() { public boolean hasSeenGroupStoryEducationSheet() {
return proto.hasSeenGroupStoryEducationSheet; return proto.hasSeenGroupStoryEducationSheet;
} }
@@ -701,11 +693,6 @@ public final class SignalAccountRecord implements SignalRecord {
return this; return this;
} }
public Builder setHasReadOnboardingStory(boolean hasReadOnboardingStory) {
builder.hasReadOnboardingStory(hasReadOnboardingStory);
return this;
}
public Builder setHasSeenGroupStoryEducationSheet(boolean hasSeenGroupStoryEducationSheet) { public Builder setHasSeenGroupStoryEducationSheet(boolean hasSeenGroupStoryEducationSheet) {
builder.hasSeenGroupStoryEducationSheet(hasSeenGroupStoryEducationSheet); builder.hasSeenGroupStoryEducationSheet(hasSeenGroupStoryEducationSheet);
return this; return this;

View File

@@ -182,7 +182,7 @@ message AccountRecord {
bool readReceipts = 6; bool readReceipts = 6;
bool sealedSenderIndicators = 7; bool sealedSenderIndicators = 7;
bool typingIndicators = 8; bool typingIndicators = 8;
bool proxiedLinkPreviews = 9; reserved /* proxiedLinkPreviews */ 9;
bool noteToSelfMarkedUnread = 10; bool noteToSelfMarkedUnread = 10;
bool linkPreviews = 11; bool linkPreviews = 11;
PhoneNumberSharingMode phoneNumberSharingMode = 12; PhoneNumberSharingMode phoneNumberSharingMode = 12;
@@ -204,7 +204,7 @@ message AccountRecord {
reserved /* storiesDisabled */ 28; reserved /* storiesDisabled */ 28;
bool storiesDisabled = 29; bool storiesDisabled = 29;
OptionalBool storyViewReceiptsEnabled = 30; OptionalBool storyViewReceiptsEnabled = 30;
bool hasReadOnboardingStory = 31; reserved /* hasReadOnboardingStory */ 31;
bool hasSeenGroupStoryEducationSheet = 32; bool hasSeenGroupStoryEducationSheet = 32;
string username = 33; string username = 33;
bool hasCompletedUsernameOnboarding = 34; bool hasCompletedUsernameOnboarding = 34;