]>
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
;
6 import org
.asamk
.signal
.manager
.GroupNotFoundException
;
7 import org
.asamk
.signal
.manager
.Manager
;
8 import org
.asamk
.signal
.util
.GroupIdFormatException
;
9 import org
.asamk
.signal
.util
.Util
;
10 import org
.whispersystems
.signalservice
.api
.util
.InvalidNumberException
;
12 public class UnblockCommand
implements LocalCommand
{
15 public void attachToSubparser(final Subparser subparser
) {
16 subparser
.addArgument("contact")
17 .help("Contact number")
19 subparser
.addArgument("-g", "--group")
22 subparser
.help("Unblock the given contacts or groups (messages will be received again)");
26 public int handleCommand(final Namespace ns
, final Manager m
) {
27 if (!m
.isRegistered()) {
28 System
.err
.println("User is not registered.");
32 for (String contact_number
: ns
.<String
>getList("contact")) {
34 m
.setContactBlocked(contact_number
, false);
35 } catch (InvalidNumberException e
) {
36 System
.err
.println(e
.getMessage());
40 if (ns
.<String
>getList("group") != null) {
41 for (String groupIdString
: ns
.<String
>getList("group")) {
43 byte[] groupId
= Util
.decodeGroupId(groupIdString
);
44 m
.setGroupBlocked(groupId
, false);
45 } catch (GroupIdFormatException
| GroupNotFoundException e
) {
46 System
.err
.println(e
.getMessage());