Search in sources :

Example 1 with GroupChangeBusyException

use of org.thoughtcrime.securesms.groups.GroupChangeBusyException in project Signal-Android by WhisperSystems.

the class GroupLinkInviteRepository method enableGroupInviteLink.

void enableGroupInviteLink(boolean requireMemberApproval, @NonNull AsynchronousCallback.WorkerThread<GroupInviteLinkUrl, EnableInviteLinkError> callback) {
    SignalExecutors.UNBOUNDED.execute(() -> {
        try {
            GroupInviteLinkUrl groupInviteLinkUrl = GroupManager.setGroupLinkEnabledState(context, groupId, requireMemberApproval ? GroupManager.GroupLinkState.ENABLED_WITH_APPROVAL : GroupManager.GroupLinkState.ENABLED);
            if (groupInviteLinkUrl == null) {
                throw new AssertionError();
            }
            callback.onComplete(groupInviteLinkUrl);
        } catch (IOException e) {
            callback.onError(EnableInviteLinkError.NETWORK_ERROR);
        } catch (GroupChangeBusyException e) {
            callback.onError(EnableInviteLinkError.BUSY);
        } catch (GroupChangeFailedException e) {
            callback.onError(EnableInviteLinkError.FAILED);
        } catch (GroupInsufficientRightsException e) {
            callback.onError(EnableInviteLinkError.INSUFFICIENT_RIGHTS);
        } catch (GroupNotAMemberException e) {
            callback.onError(EnableInviteLinkError.NOT_IN_GROUP);
        }
    });
}
Also used : GroupChangeFailedException(org.thoughtcrime.securesms.groups.GroupChangeFailedException) GroupChangeBusyException(org.thoughtcrime.securesms.groups.GroupChangeBusyException) GroupNotAMemberException(org.thoughtcrime.securesms.groups.GroupNotAMemberException) GroupInviteLinkUrl(org.thoughtcrime.securesms.groups.v2.GroupInviteLinkUrl) GroupInsufficientRightsException(org.thoughtcrime.securesms.groups.GroupInsufficientRightsException) IOException(java.io.IOException)

Example 2 with GroupChangeBusyException

use of org.thoughtcrime.securesms.groups.GroupChangeBusyException in project Signal-Android by signalapp.

the class GroupLinkInviteRepository method enableGroupInviteLink.

void enableGroupInviteLink(boolean requireMemberApproval, @NonNull AsynchronousCallback.WorkerThread<GroupInviteLinkUrl, EnableInviteLinkError> callback) {
    SignalExecutors.UNBOUNDED.execute(() -> {
        try {
            GroupInviteLinkUrl groupInviteLinkUrl = GroupManager.setGroupLinkEnabledState(context, groupId, requireMemberApproval ? GroupManager.GroupLinkState.ENABLED_WITH_APPROVAL : GroupManager.GroupLinkState.ENABLED);
            if (groupInviteLinkUrl == null) {
                throw new AssertionError();
            }
            callback.onComplete(groupInviteLinkUrl);
        } catch (IOException e) {
            callback.onError(EnableInviteLinkError.NETWORK_ERROR);
        } catch (GroupChangeBusyException e) {
            callback.onError(EnableInviteLinkError.BUSY);
        } catch (GroupChangeFailedException e) {
            callback.onError(EnableInviteLinkError.FAILED);
        } catch (GroupInsufficientRightsException e) {
            callback.onError(EnableInviteLinkError.INSUFFICIENT_RIGHTS);
        } catch (GroupNotAMemberException e) {
            callback.onError(EnableInviteLinkError.NOT_IN_GROUP);
        }
    });
}
Also used : GroupChangeFailedException(org.thoughtcrime.securesms.groups.GroupChangeFailedException) GroupChangeBusyException(org.thoughtcrime.securesms.groups.GroupChangeBusyException) GroupNotAMemberException(org.thoughtcrime.securesms.groups.GroupNotAMemberException) GroupInviteLinkUrl(org.thoughtcrime.securesms.groups.v2.GroupInviteLinkUrl) GroupInsufficientRightsException(org.thoughtcrime.securesms.groups.GroupInsufficientRightsException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 GroupChangeBusyException (org.thoughtcrime.securesms.groups.GroupChangeBusyException)2 GroupChangeFailedException (org.thoughtcrime.securesms.groups.GroupChangeFailedException)2 GroupInsufficientRightsException (org.thoughtcrime.securesms.groups.GroupInsufficientRightsException)2 GroupNotAMemberException (org.thoughtcrime.securesms.groups.GroupNotAMemberException)2 GroupInviteLinkUrl (org.thoughtcrime.securesms.groups.v2.GroupInviteLinkUrl)2