Search in sources :

Example 1 with ReportSpamJob

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

the class MessageRequestRepository method blockAndReportSpamMessageRequest.

void blockAndReportSpamMessageRequest(@NonNull LiveRecipient liveRecipient, long threadId, @NonNull Runnable onMessageRequestBlocked, @NonNull GroupChangeErrorCallback error) {
    executor.execute(() -> {
        Recipient recipient = liveRecipient.resolve();
        try {
            RecipientUtil.block(context, recipient);
        } catch (GroupChangeException | IOException e) {
            Log.w(TAG, e);
            error.onError(GroupChangeFailureReason.fromException(e));
            return;
        }
        liveRecipient.refresh();
        ApplicationDependencies.getJobManager().add(new ReportSpamJob(threadId, System.currentTimeMillis()));
        if (TextSecurePreferences.isMultiDevice(context)) {
            ApplicationDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forBlockAndReportSpam(liveRecipient.getId()));
        }
        onMessageRequestBlocked.run();
    });
}
Also used : ReportSpamJob(org.thoughtcrime.securesms.jobs.ReportSpamJob) GroupChangeException(org.thoughtcrime.securesms.groups.GroupChangeException) Recipient(org.thoughtcrime.securesms.recipients.Recipient) LiveRecipient(org.thoughtcrime.securesms.recipients.LiveRecipient) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 GroupChangeException (org.thoughtcrime.securesms.groups.GroupChangeException)1 ReportSpamJob (org.thoughtcrime.securesms.jobs.ReportSpamJob)1 LiveRecipient (org.thoughtcrime.securesms.recipients.LiveRecipient)1 Recipient (org.thoughtcrime.securesms.recipients.Recipient)1