Search in sources :

Example 1 with RotateProfileKeyJob

use of org.thoughtcrime.securesms.jobs.RotateProfileKeyJob in project mollyim-android by mollyim.

the class RecipientUtil method block.

/**
 * You can call this for any type of recipient but must handle network errors that can occur from
 * GV2.
 * <p>
 * GV2 operations can also take longer due to the network.
 */
@WorkerThread
public static void block(@NonNull Context context, @NonNull Recipient recipient) throws GroupChangeBusyException, IOException, GroupChangeFailedException {
    if (!isBlockable(recipient)) {
        throw new AssertionError("Recipient is not blockable!");
    }
    recipient = recipient.resolve();
    if (recipient.isGroup() && recipient.getGroupId().get().isPush() && recipient.isActiveGroup()) {
        GroupManager.leaveGroupFromBlockOrMessageRequest(context, recipient.getGroupId().get().requirePush());
    }
    SignalDatabase.recipients().setBlocked(recipient.getId(), true);
    if (recipient.isSystemContact() || recipient.isProfileSharing() || isProfileSharedViaGroup(recipient)) {
        ApplicationDependencies.getJobManager().add(new RotateProfileKeyJob());
        SignalDatabase.recipients().setProfileSharing(recipient.getId(), false);
    }
    ApplicationDependencies.getJobManager().add(new MultiDeviceBlockedUpdateJob());
    StorageSyncHelper.scheduleSyncForDataChange();
}
Also used : RotateProfileKeyJob(org.thoughtcrime.securesms.jobs.RotateProfileKeyJob) MultiDeviceBlockedUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob) WorkerThread(androidx.annotation.WorkerThread)

Example 2 with RotateProfileKeyJob

use of org.thoughtcrime.securesms.jobs.RotateProfileKeyJob in project mollyim-android by mollyim.

the class RecipientUtil method delete.

@WorkerThread
public static void delete(@NonNull Context context, @NonNull Recipient recipient) {
    Recipient resolved = recipient.resolve();
    ThreadDatabase threadDatabase = SignalDatabase.threads();
    long existingThread = threadDatabase.getThreadIdIfExistsFor(resolved.getId());
    if (existingThread > -1) {
        threadDatabase.deleteConversation(existingThread);
        ApplicationDependencies.getMessageNotifier().updateNotification(context);
    }
    if (recipient.isSystemContact() && recipient.getContactUri() != null) {
        SignalDatabase.contacts().lookupAndDeleteContact(recipient.getContactUri());
    }
    SignalDatabase.recipients().clearFieldsForDeletion(resolved.getId());
    NotificationChannels.deleteChannelFor(context, resolved);
    if (!resolved.isBlocked()) {
        ApplicationDependencies.getJobManager().add(new RotateProfileKeyJob());
    }
    if (TextSecurePreferences.isMultiDevice(context)) {
        ApplicationDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forDelete(recipient.getId()));
    }
}
Also used : ThreadDatabase(org.thoughtcrime.securesms.database.ThreadDatabase) RotateProfileKeyJob(org.thoughtcrime.securesms.jobs.RotateProfileKeyJob) WorkerThread(androidx.annotation.WorkerThread)

Example 3 with RotateProfileKeyJob

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

the class RecipientUtil method block.

/**
 * You can call this for any type of recipient but must handle network errors that can occur from
 * GV2.
 * <p>
 * GV2 operations can also take longer due to the network.
 */
@WorkerThread
public static void block(@NonNull Context context, @NonNull Recipient recipient) throws GroupChangeBusyException, IOException, GroupChangeFailedException {
    if (!isBlockable(recipient)) {
        throw new AssertionError("Recipient is not blockable!");
    }
    recipient = recipient.resolve();
    if (recipient.isGroup() && recipient.getGroupId().get().isPush() && recipient.isActiveGroup()) {
        GroupManager.leaveGroupFromBlockOrMessageRequest(context, recipient.getGroupId().get().requirePush());
    }
    SignalDatabase.recipients().setBlocked(recipient.getId(), true);
    if (recipient.isSystemContact() || recipient.isProfileSharing() || isProfileSharedViaGroup(context, recipient)) {
        ApplicationDependencies.getJobManager().add(new RotateProfileKeyJob());
        SignalDatabase.recipients().setProfileSharing(recipient.getId(), false);
    }
    ApplicationDependencies.getJobManager().add(new MultiDeviceBlockedUpdateJob());
    StorageSyncHelper.scheduleSyncForDataChange();
}
Also used : RotateProfileKeyJob(org.thoughtcrime.securesms.jobs.RotateProfileKeyJob) MultiDeviceBlockedUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob) WorkerThread(androidx.annotation.WorkerThread)

Example 4 with RotateProfileKeyJob

use of org.thoughtcrime.securesms.jobs.RotateProfileKeyJob in project Signal-Android by signalapp.

the class RecipientUtil method block.

/**
 * You can call this for any type of recipient but must handle network errors that can occur from
 * GV2.
 * <p>
 * GV2 operations can also take longer due to the network.
 */
@WorkerThread
public static void block(@NonNull Context context, @NonNull Recipient recipient) throws GroupChangeBusyException, IOException, GroupChangeFailedException {
    if (!isBlockable(recipient)) {
        throw new AssertionError("Recipient is not blockable!");
    }
    recipient = recipient.resolve();
    if (recipient.isGroup() && recipient.getGroupId().get().isPush() && recipient.isActiveGroup()) {
        GroupManager.leaveGroupFromBlockOrMessageRequest(context, recipient.getGroupId().get().requirePush());
    }
    SignalDatabase.recipients().setBlocked(recipient.getId(), true);
    if (recipient.isSystemContact() || recipient.isProfileSharing() || isProfileSharedViaGroup(context, recipient)) {
        ApplicationDependencies.getJobManager().add(new RotateProfileKeyJob());
        SignalDatabase.recipients().setProfileSharing(recipient.getId(), false);
    }
    ApplicationDependencies.getJobManager().add(new MultiDeviceBlockedUpdateJob());
    StorageSyncHelper.scheduleSyncForDataChange();
}
Also used : RotateProfileKeyJob(org.thoughtcrime.securesms.jobs.RotateProfileKeyJob) MultiDeviceBlockedUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob) WorkerThread(androidx.annotation.WorkerThread)

Aggregations

WorkerThread (androidx.annotation.WorkerThread)4 RotateProfileKeyJob (org.thoughtcrime.securesms.jobs.RotateProfileKeyJob)4 MultiDeviceBlockedUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob)3 ThreadDatabase (org.thoughtcrime.securesms.database.ThreadDatabase)1