]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/Manager.java
Prevent updateContact and block commands on linked devices
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / Manager.java
index 827d6d91742c6db4d9d5f1eef99accc863cd8b8c..38f37ed2a1d417dcc7343e42201b0feaa6b5b2fe 100644 (file)
@@ -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);
     }