use of org.thoughtcrime.securesms.groups.GroupChangeException 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();
});
}
use of org.thoughtcrime.securesms.groups.GroupChangeException in project Signal-Android by WhisperSystems.
the class MessageRequestRepository method acceptMessageRequest.
void acceptMessageRequest(@NonNull LiveRecipient liveRecipient, long threadId, @NonNull Runnable onMessageRequestAccepted, @NonNull GroupChangeErrorCallback error) {
executor.execute(() -> {
if (liveRecipient.get().isPushV2Group()) {
try {
Log.i(TAG, "GV2 accepting invite");
GroupManager.acceptInvite(context, liveRecipient.get().requireGroupId().requireV2());
RecipientDatabase recipientDatabase = SignalDatabase.recipients();
recipientDatabase.setProfileSharing(liveRecipient.getId(), true);
onMessageRequestAccepted.run();
} catch (GroupChangeException | IOException e) {
Log.w(TAG, e);
error.onError(GroupChangeFailureReason.fromException(e));
}
} else {
RecipientDatabase recipientDatabase = SignalDatabase.recipients();
recipientDatabase.setProfileSharing(liveRecipient.getId(), true);
MessageSender.sendProfileKey(context, threadId);
List<MessageDatabase.MarkedMessageInfo> messageIds = SignalDatabase.threads().setEntireThreadRead(threadId);
ApplicationDependencies.getMessageNotifier().updateNotification(context);
MarkReadReceiver.process(context, messageIds);
List<MessageDatabase.MarkedMessageInfo> viewedInfos = SignalDatabase.mms().getViewedIncomingMessages(threadId);
SendViewedReceiptJob.enqueue(threadId, liveRecipient.getId(), viewedInfos);
if (TextSecurePreferences.isMultiDevice(context)) {
ApplicationDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forAccept(liveRecipient.getId()));
}
onMessageRequestAccepted.run();
}
});
}
use of org.thoughtcrime.securesms.groups.GroupChangeException 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();
});
}
use of org.thoughtcrime.securesms.groups.GroupChangeException in project Signal-Android by WhisperSystems.
the class MessageRequestRepository method blockMessageRequest.
void blockMessageRequest(@NonNull LiveRecipient liveRecipient, @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();
if (TextSecurePreferences.isMultiDevice(context)) {
ApplicationDependencies.getJobManager().add(MultiDeviceMessageRequestResponseJob.forBlock(liveRecipient.getId()));
}
onMessageRequestBlocked.run();
});
}
Aggregations