mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Improve error message when joining a group with already pending admin approval
This commit is contained in:
parent
a708025a16
commit
489fb2ac22
6 changed files with 27 additions and 3 deletions
|
@ -12,6 +12,7 @@ import org.asamk.signal.manager.api.Message;
|
|||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
|
||||
import org.asamk.signal.manager.api.Pair;
|
||||
import org.asamk.signal.manager.api.PendingAdminApprovalException;
|
||||
import org.asamk.signal.manager.api.ReceiveConfig;
|
||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
||||
|
@ -108,7 +109,7 @@ public interface Manager extends Closeable {
|
|||
|
||||
Pair<GroupId, SendGroupMessageResults> joinGroup(
|
||||
GroupInviteLinkUrl inviteLinkUrl
|
||||
) throws IOException, InactiveGroupLinkException;
|
||||
) throws IOException, InactiveGroupLinkException, PendingAdminApprovalException;
|
||||
|
||||
SendMessageResults sendTypingMessage(
|
||||
TypingAction action, Set<RecipientIdentifier> recipients
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.asamk.signal.manager.api.InvalidStickerException;
|
|||
import org.asamk.signal.manager.api.Message;
|
||||
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
|
||||
import org.asamk.signal.manager.api.Pair;
|
||||
import org.asamk.signal.manager.api.PendingAdminApprovalException;
|
||||
import org.asamk.signal.manager.api.ReceiveConfig;
|
||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
||||
|
@ -431,7 +432,7 @@ class ManagerImpl implements Manager {
|
|||
@Override
|
||||
public Pair<GroupId, SendGroupMessageResults> joinGroup(
|
||||
GroupInviteLinkUrl inviteLinkUrl
|
||||
) throws IOException, InactiveGroupLinkException {
|
||||
) throws IOException, InactiveGroupLinkException, PendingAdminApprovalException {
|
||||
return context.getGroupHelper().joinGroup(inviteLinkUrl);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package org.asamk.signal.manager.api;
|
||||
|
||||
public class PendingAdminApprovalException extends Exception {
|
||||
|
||||
public PendingAdminApprovalException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public PendingAdminApprovalException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import org.asamk.signal.manager.SignalDependencies;
|
|||
import org.asamk.signal.manager.api.AttachmentInvalidException;
|
||||
import org.asamk.signal.manager.api.InactiveGroupLinkException;
|
||||
import org.asamk.signal.manager.api.Pair;
|
||||
import org.asamk.signal.manager.api.PendingAdminApprovalException;
|
||||
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
||||
import org.asamk.signal.manager.api.SendMessageResult;
|
||||
import org.asamk.signal.manager.config.ServiceConfig;
|
||||
|
@ -290,7 +291,7 @@ public class GroupHelper {
|
|||
|
||||
public Pair<GroupId, SendGroupMessageResults> joinGroup(
|
||||
GroupInviteLinkUrl inviteLinkUrl
|
||||
) throws IOException, InactiveGroupLinkException {
|
||||
) throws IOException, InactiveGroupLinkException, PendingAdminApprovalException {
|
||||
final DecryptedGroupJoinInfo groupJoinInfo;
|
||||
try {
|
||||
groupJoinInfo = context.getGroupV2Helper()
|
||||
|
@ -298,6 +299,9 @@ public class GroupHelper {
|
|||
} catch (GroupLinkNotActiveException e) {
|
||||
throw new InactiveGroupLinkException("Group link inactive (reason: " + e.getReason() + ")", e);
|
||||
}
|
||||
if (groupJoinInfo.getPendingAdminApproval()) {
|
||||
throw new PendingAdminApprovalException("You have already requested to join the group.");
|
||||
}
|
||||
final var groupChange = context.getGroupV2Helper()
|
||||
.joinGroup(inviteLinkUrl.getGroupMasterKey(), inviteLinkUrl.getPassword(), groupJoinInfo);
|
||||
final var group = getOrMigrateGroup(inviteLinkUrl.getGroupMasterKey(),
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
|||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.api.InactiveGroupLinkException;
|
||||
import org.asamk.signal.manager.api.PendingAdminApprovalException;
|
||||
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
|
||||
import org.asamk.signal.output.JsonWriter;
|
||||
import org.asamk.signal.output.OutputWriter;
|
||||
|
@ -94,6 +95,8 @@ public class JoinGroupCommand implements JsonRpcLocalCommand {
|
|||
.getSimpleName() + ")", e);
|
||||
} catch (InactiveGroupLinkException e) {
|
||||
throw new UserErrorException("Group link is not valid: " + e.getMessage());
|
||||
} catch (PendingAdminApprovalException e) {
|
||||
throw new UserErrorException("Pending admin approval: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.asamk.signal.manager.api.InvalidNumberException;
|
|||
import org.asamk.signal.manager.api.InvalidStickerException;
|
||||
import org.asamk.signal.manager.api.Message;
|
||||
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
|
||||
import org.asamk.signal.manager.api.PendingAdminApprovalException;
|
||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||
import org.asamk.signal.manager.api.SendMessageResult;
|
||||
import org.asamk.signal.manager.api.SendMessageResults;
|
||||
|
@ -778,6 +779,8 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
final var result = m.joinGroup(linkUrl);
|
||||
return result.first().serialize();
|
||||
} catch (PendingAdminApprovalException e) {
|
||||
throw new Error.Failure("Pending admin approval: " + e.getMessage());
|
||||
} catch (GroupInviteLinkUrl.InvalidGroupLinkException | InactiveGroupLinkException e) {
|
||||
throw new Error.Failure("Group link is invalid: " + e.getMessage());
|
||||
} catch (GroupInviteLinkUrl.UnknownGroupLinkVersionException e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue