mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 04:20:38 +00:00
Use only one method for blocking and unblocking
This commit is contained in:
parent
3a3d9545ea
commit
5ab3152a40
4 changed files with 7 additions and 24 deletions
|
@ -24,9 +24,7 @@ public interface Signal extends DBusInterface {
|
|||
|
||||
void setContactName(String number, String name);
|
||||
|
||||
void blockContact(String number);
|
||||
|
||||
void unblockContact(String number);
|
||||
void setContactBlocked(String number, boolean blocked);
|
||||
|
||||
List<byte[]> getGroupIds();
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public class BlockContactCommand implements LocalCommand {
|
|||
|
||||
String number = ns.getString("number");
|
||||
|
||||
m.blockContact(number);
|
||||
m.setContactBlocked(number, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class UnblockContactCommand implements LocalCommand {
|
|||
|
||||
String number = ns.getString("number");
|
||||
|
||||
m.unblockContact(number);
|
||||
m.setContactBlocked(number, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -687,31 +687,16 @@ public class Manager implements Signal {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void blockContact(String number) {
|
||||
public void setContactBlocked(String number, boolean blocked) {
|
||||
ContactInfo contact = account.getContactStore().getContact(number);
|
||||
if (contact == null) {
|
||||
contact = new ContactInfo();
|
||||
contact.number = number;
|
||||
System.err.println("Adding and blocking contact " + number);
|
||||
System.err.println("Adding and " + (blocked ? "blocking" : "unblocking") + " contact " + number);
|
||||
} else {
|
||||
System.err.println("Blocking contact " + number);
|
||||
System.err.println((blocked ? "Blocking" : "Unblocking") + " contact " + number);
|
||||
}
|
||||
contact.blocked = true;
|
||||
account.getContactStore().updateContact(contact);
|
||||
account.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unblockContact(String number) {
|
||||
ContactInfo contact = account.getContactStore().getContact(number);
|
||||
if (contact == null) {
|
||||
contact = new ContactInfo();
|
||||
contact.number = number;
|
||||
System.err.println("Adding and unblocking contact " + number);
|
||||
} else {
|
||||
System.err.println("Unblocking contact " + number);
|
||||
}
|
||||
contact.blocked = false;
|
||||
contact.blocked = blocked;
|
||||
account.getContactStore().updateContact(contact);
|
||||
account.save();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue