Search in sources :

Example 1 with RetrieveProfileAvatarJob

use of org.thoughtcrime.securesms.jobs.RetrieveProfileAvatarJob in project Signal-Android by WhisperSystems.

the class RecipientIdJobMigrationTest method migrate_retrieveProfileAvatarJob.

@Test
public void migrate_retrieveProfileAvatarJob() throws Exception {
    JobData testData = new JobData("RetrieveProfileAvatarJob", "RetrieveProfileAvatarJob+16101234567", new Data.Builder().putString("address", "+16101234567").putString("profile_avatar", "abc").build());
    mockRecipientResolve("+16101234567", 1);
    RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
    JobData converted = subject.migrate(testData);
    assertEquals("RetrieveProfileAvatarJob", converted.getFactoryKey());
    assertEquals("RetrieveProfileAvatarJob::" + RecipientId.from(1).toQueueKey(), converted.getQueueKey());
    assertEquals("1", converted.getData().getString("recipient"));
    new RetrieveProfileAvatarJob.Factory().create(mock(Job.Parameters.class), converted.getData());
}
Also used : RetrieveProfileAvatarJob(org.thoughtcrime.securesms.jobs.RetrieveProfileAvatarJob) JobData(org.thoughtcrime.securesms.jobmanager.JobMigration.JobData) Application(android.app.Application) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with RetrieveProfileAvatarJob

use of org.thoughtcrime.securesms.jobs.RetrieveProfileAvatarJob in project Signal-Android by WhisperSystems.

the class StorageSyncHelper method applyAccountStorageSyncUpdates.

public static void applyAccountStorageSyncUpdates(@NonNull Context context, @NonNull Recipient self, @NonNull StorageRecordUpdate<SignalAccountRecord> update, boolean fetchProfile) {
    SignalDatabase.recipients().applyStorageSyncAccountUpdate(update);
    TextSecurePreferences.setReadReceiptsEnabled(context, update.getNew().isReadReceiptsEnabled());
    TextSecurePreferences.setTypingIndicatorsEnabled(context, update.getNew().isTypingIndicatorsEnabled());
    TextSecurePreferences.setShowUnidentifiedDeliveryIndicatorsEnabled(context, update.getNew().isSealedSenderIndicatorsEnabled());
    SignalStore.settings().setLinkPreviewsEnabled(update.getNew().isLinkPreviewsEnabled());
    SignalStore.phoneNumberPrivacy().setPhoneNumberListingMode(update.getNew().isPhoneNumberUnlisted() ? PhoneNumberPrivacyValues.PhoneNumberListingMode.UNLISTED : PhoneNumberPrivacyValues.PhoneNumberListingMode.LISTED);
    SignalStore.phoneNumberPrivacy().setPhoneNumberSharingMode(StorageSyncModels.remoteToLocalPhoneNumberSharingMode(update.getNew().getPhoneNumberSharingMode()));
    SignalStore.settings().setPreferSystemContactPhotos(update.getNew().isPreferContactAvatars());
    SignalStore.paymentsValues().setEnabledAndEntropy(update.getNew().getPayments().isEnabled(), Entropy.fromBytes(update.getNew().getPayments().getEntropy().orNull()));
    SignalStore.settings().setUniversalExpireTimer(update.getNew().getUniversalExpireTimer());
    SignalStore.emojiValues().setReactions(update.getNew().getDefaultReactions());
    SignalStore.donationsValues().setDisplayBadgesOnProfile(update.getNew().isDisplayBadgesOnProfile());
    if (update.getNew().isSubscriptionManuallyCancelled()) {
        SignalStore.donationsValues().markUserManuallyCancelled();
        SignalStore.donationsValues().setUnexpectedSubscriptionCancelationReason(null);
    } else {
        SignalStore.donationsValues().clearUserManuallyCancelled();
    }
    Subscriber subscriber = StorageSyncModels.remoteToLocalSubscriber(update.getNew().getSubscriber());
    if (subscriber != null) {
        SignalStore.donationsValues().setSubscriber(subscriber);
    }
    if (fetchProfile && update.getNew().getAvatarUrlPath().isPresent()) {
        ApplicationDependencies.getJobManager().add(new RetrieveProfileAvatarJob(self, update.getNew().getAvatarUrlPath().get()));
    }
}
Also used : RetrieveProfileAvatarJob(org.thoughtcrime.securesms.jobs.RetrieveProfileAvatarJob) Subscriber(org.thoughtcrime.securesms.subscription.Subscriber)

Aggregations

RetrieveProfileAvatarJob (org.thoughtcrime.securesms.jobs.RetrieveProfileAvatarJob)2 Application (android.app.Application)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 JobData (org.thoughtcrime.securesms.jobmanager.JobMigration.JobData)1 Subscriber (org.thoughtcrime.securesms.subscription.Subscriber)1