+ @Override
+ public void setContactBlocked(String number, boolean blocked) throws InvalidNumberException {
+ number = Utils.canonicalizeNumber(number, username);
+ ContactInfo contact = account.getContactStore().getContact(number);
+ if (contact == null) {
+ contact = new ContactInfo();
+ contact.number = number;
+ System.err.println("Adding and " + (blocked ? "blocking" : "unblocking") + " contact " + number);
+ } else {
+ System.err.println((blocked ? "Blocking" : "Unblocking") + " contact " + number);
+ }
+ contact.blocked = blocked;
+ account.getContactStore().updateContact(contact);
+ account.save();
+ }
+
+ @Override
+ public void setGroupBlocked(final byte[] groupId, final boolean blocked) throws GroupNotFoundException {
+ GroupInfo group = getGroup(groupId);
+ if (group == null) {
+ throw new GroupNotFoundException(groupId);
+ } else {
+ System.err.println((blocked ? "Blocking" : "Unblocking") + " group " + Base64.encodeBytes(groupId));
+ group.blocked = blocked;
+ account.getGroupStore().updateGroup(group);
+ account.save();
+ }
+ }
+