mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Prevent updateContact and block commands on linked devices
The changes would be overwritten with the next sync anyway Fixes #600
This commit is contained in:
parent
312c6c8bb2
commit
36475bb632
6 changed files with 38 additions and 5 deletions
|
@ -1088,14 +1088,22 @@ public class Manager implements Closeable {
|
|||
return contact == null || contact.getName() == null ? "" : contact.getName();
|
||||
}
|
||||
|
||||
public void setContactName(String number, String name) throws InvalidNumberException {
|
||||
public void setContactName(String number, String name) throws InvalidNumberException, NotMasterDeviceException {
|
||||
if (!account.isMasterDevice()) {
|
||||
throw new NotMasterDeviceException();
|
||||
}
|
||||
final var recipientId = canonicalizeAndResolveRecipient(number);
|
||||
var contact = account.getContactStore().getContact(recipientId);
|
||||
final var builder = contact == null ? Contact.newBuilder() : Contact.newBuilder(contact);
|
||||
account.getContactStore().storeContact(recipientId, builder.withName(name).build());
|
||||
}
|
||||
|
||||
public void setContactBlocked(String number, boolean blocked) throws InvalidNumberException {
|
||||
public void setContactBlocked(
|
||||
String number, boolean blocked
|
||||
) throws InvalidNumberException, NotMasterDeviceException {
|
||||
if (!account.isMasterDevice()) {
|
||||
throw new NotMasterDeviceException();
|
||||
}
|
||||
setContactBlocked(canonicalizeAndResolveRecipient(number), blocked);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package org.asamk.signal.manager;
|
||||
|
||||
public class NotMasterDeviceException extends Exception {
|
||||
|
||||
public NotMasterDeviceException() {
|
||||
super("This function is not supported for linked devices.");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue