]>
nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/commands/UnblockCommand.java
1 package org
.asamk
.signal
.commands
;
3 import net
.sourceforge
.argparse4j
.inf
.Namespace
;
4 import net
.sourceforge
.argparse4j
.inf
.Subparser
;
5 import org
.asamk
.signal
.GroupIdFormatException
;
6 import org
.asamk
.signal
.GroupNotFoundException
;
7 import org
.asamk
.signal
.manager
.Manager
;
8 import org
.asamk
.signal
.util
.Util
;
9 import org
.whispersystems
.signalservice
.api
.util
.InvalidNumberException
;
11 public class UnblockCommand
implements LocalCommand
{
14 public void attachToSubparser(final Subparser subparser
) {
15 subparser
.addArgument("contact")
16 .help("Contact number")
18 subparser
.addArgument("-g", "--group")
21 subparser
.help("Unblock the given contacts or groups (messages will be received again)");
25 public int handleCommand(final Namespace ns
, final Manager m
) {
26 if (!m
.isRegistered()) {
27 System
.err
.println("User is not registered.");
31 for (String contact_number
: ns
.<String
>getList("contact")) {
33 m
.setContactBlocked(contact_number
, false);
34 } catch (InvalidNumberException e
) {
35 System
.err
.println(e
.getMessage());
39 if (ns
.<String
>getList("group") != null) {
40 for (String groupIdString
: ns
.<String
>getList("group")) {
42 byte[] groupId
= Util
.decodeGroupId(groupIdString
);
43 m
.setGroupBlocked(groupId
, false);
44 } catch (GroupIdFormatException
| GroupNotFoundException e
) {
45 System
.err
.println(e
.getMessage());