mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 12:30:39 +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 setContactName(String number, String name);
|
||||||
|
|
||||||
void blockContact(String number);
|
void setContactBlocked(String number, boolean blocked);
|
||||||
|
|
||||||
void unblockContact(String number);
|
|
||||||
|
|
||||||
List<byte[]> getGroupIds();
|
List<byte[]> getGroupIds();
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class BlockContactCommand implements LocalCommand {
|
||||||
|
|
||||||
String number = ns.getString("number");
|
String number = ns.getString("number");
|
||||||
|
|
||||||
m.blockContact(number);
|
m.setContactBlocked(number, true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class UnblockContactCommand implements LocalCommand {
|
||||||
|
|
||||||
String number = ns.getString("number");
|
String number = ns.getString("number");
|
||||||
|
|
||||||
m.unblockContact(number);
|
m.setContactBlocked(number, false);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -687,31 +687,16 @@ public class Manager implements Signal {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void blockContact(String number) {
|
public void setContactBlocked(String number, boolean blocked) {
|
||||||
ContactInfo contact = account.getContactStore().getContact(number);
|
ContactInfo contact = account.getContactStore().getContact(number);
|
||||||
if (contact == null) {
|
if (contact == null) {
|
||||||
contact = new ContactInfo();
|
contact = new ContactInfo();
|
||||||
contact.number = number;
|
contact.number = number;
|
||||||
System.err.println("Adding and blocking contact " + number);
|
System.err.println("Adding and " + (blocked ? "blocking" : "unblocking") + " contact " + number);
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Blocking contact " + number);
|
System.err.println((blocked ? "Blocking" : "Unblocking") + " contact " + number);
|
||||||
}
|
}
|
||||||
contact.blocked = true;
|
contact.blocked = blocked;
|
||||||
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;
|
|
||||||
account.getContactStore().updateContact(contact);
|
account.getContactStore().updateContact(contact);
|
||||||
account.save();
|
account.save();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue