Search in sources :

Example 1 with GroupPatchNotAcceptedException

use of org.whispersystems.signalservice.internal.push.exceptions.GroupPatchNotAcceptedException in project Signal-Android by WhisperSystems.

the class MessageRequestRepository method deleteMessageRequest.

void deleteMessageRequest(@NonNull LiveRecipient recipient, long threadId, @NonNull Runnable onMessageRequestDeleted, @NonNull GroupChangeErrorCallback error) {
    executor.execute(() -> {
        Recipient resolved = recipient.resolve();
        if (resolved.isGroup() && resolved.requireGroupId().isPush()) {
            try {
                GroupManager.leaveGroupFromBlockOrMessageRequest(context, resolved.requireGroupId().requirePush());
            } catch (GroupChangeException | GroupPatchNotAcceptedException e) {
                if (SignalDatabase.groups().isCurrentMember(resolved.requireGroupId().requirePush(), Recipient.self().getId())) {
                    Log.w(TAG, "Failed to leave group, and we're still a member.", e);
                    error.onError(GroupChangeFailureReason.fromException(e));
                    return;
                } else {
                    Log.w(TAG, "Failed to leave group, but we're not a member, so ignoring.");
                }
            } catch (IOException e) {
                Log.w(TAG, e);
                error.onError(GroupChangeFailureReason.fromException(e));
                return;
            }
        }
        if (TextSecurePreferences.isMultiDevice(context)) {
            ApplicationDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forDelete(recipient.getId()));
        }
        ThreadDatabase threadDatabase = SignalDatabase.threads();
        threadDatabase.deleteConversation(threadId);
        onMessageRequestDeleted.run();
    });
}
Also used : GroupPatchNotAcceptedException(org.whispersystems.signalservice.internal.push.exceptions.GroupPatchNotAcceptedException) GroupChangeException(org.thoughtcrime.securesms.groups.GroupChangeException) Recipient(org.thoughtcrime.securesms.recipients.Recipient) LiveRecipient(org.thoughtcrime.securesms.recipients.LiveRecipient) IOException(java.io.IOException) ThreadDatabase(org.thoughtcrime.securesms.database.ThreadDatabase)

Example 2 with GroupPatchNotAcceptedException

use of org.whispersystems.signalservice.internal.push.exceptions.GroupPatchNotAcceptedException in project Signal-Android by signalapp.

the class MessageRequestRepository method deleteMessageRequest.

void deleteMessageRequest(@NonNull LiveRecipient recipient, long threadId, @NonNull Runnable onMessageRequestDeleted, @NonNull GroupChangeErrorCallback error) {
    executor.execute(() -> {
        Recipient resolved = recipient.resolve();
        if (resolved.isGroup() && resolved.requireGroupId().isPush()) {
            try {
                GroupManager.leaveGroupFromBlockOrMessageRequest(context, resolved.requireGroupId().requirePush());
            } catch (GroupChangeException | GroupPatchNotAcceptedException e) {
                if (SignalDatabase.groups().isCurrentMember(resolved.requireGroupId().requirePush(), Recipient.self().getId())) {
                    Log.w(TAG, "Failed to leave group, and we're still a member.", e);
                    error.onError(GroupChangeFailureReason.fromException(e));
                    return;
                } else {
                    Log.w(TAG, "Failed to leave group, but we're not a member, so ignoring.");
                }
            } catch (IOException e) {
                Log.w(TAG, e);
                error.onError(GroupChangeFailureReason.fromException(e));
                return;
            }
        }
        if (TextSecurePreferences.isMultiDevice(context)) {
            ApplicationDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forDelete(recipient.getId()));
        }
        ThreadDatabase threadDatabase = SignalDatabase.threads();
        threadDatabase.deleteConversation(threadId);
        onMessageRequestDeleted.run();
    });
}
Also used : GroupPatchNotAcceptedException(org.whispersystems.signalservice.internal.push.exceptions.GroupPatchNotAcceptedException) GroupChangeException(org.thoughtcrime.securesms.groups.GroupChangeException) Recipient(org.thoughtcrime.securesms.recipients.Recipient) LiveRecipient(org.thoughtcrime.securesms.recipients.LiveRecipient) IOException(java.io.IOException) ThreadDatabase(org.thoughtcrime.securesms.database.ThreadDatabase)

Aggregations

IOException (java.io.IOException)2 ThreadDatabase (org.thoughtcrime.securesms.database.ThreadDatabase)2 GroupChangeException (org.thoughtcrime.securesms.groups.GroupChangeException)2 LiveRecipient (org.thoughtcrime.securesms.recipients.LiveRecipient)2 Recipient (org.thoughtcrime.securesms.recipients.Recipient)2 GroupPatchNotAcceptedException (org.whispersystems.signalservice.internal.push.exceptions.GroupPatchNotAcceptedException)2