Improve error message when joining a group with already pending admin approval

This commit is contained in:
AsamK 2022-10-07 19:31:27 +02:00
parent a708025a16
commit 489fb2ac22
6 changed files with 27 additions and 3 deletions

View file

@ -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());
}
}
}

View file

@ -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) {