]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/Manager.java
Add sendSyncRequest command
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / Manager.java
index 827d6d91742c6db4d9d5f1eef99accc863cd8b8c..99f71563a7978e494bc8f8d467e95a013174d62f 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);
     }
 
@@ -1184,7 +1192,15 @@ public class Manager implements Closeable {
         }
     }
 
-    void requestSyncGroups() throws IOException {
+    public void requestAllSyncData() throws IOException {
+        requestSyncGroups();
+        requestSyncContacts();
+        requestSyncBlocked();
+        requestSyncConfiguration();
+        requestSyncKeys();
+    }
+
+    private void requestSyncGroups() throws IOException {
         var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
                 .setType(SignalServiceProtos.SyncMessage.Request.Type.GROUPS)
                 .build();
@@ -1196,7 +1212,7 @@ public class Manager implements Closeable {
         }
     }
 
-    void requestSyncContacts() throws IOException {
+    private void requestSyncContacts() throws IOException {
         var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
                 .setType(SignalServiceProtos.SyncMessage.Request.Type.CONTACTS)
                 .build();
@@ -1208,7 +1224,7 @@ public class Manager implements Closeable {
         }
     }
 
-    void requestSyncBlocked() throws IOException {
+    private void requestSyncBlocked() throws IOException {
         var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
                 .setType(SignalServiceProtos.SyncMessage.Request.Type.BLOCKED)
                 .build();
@@ -1220,7 +1236,7 @@ public class Manager implements Closeable {
         }
     }
 
-    void requestSyncConfiguration() throws IOException {
+    private void requestSyncConfiguration() throws IOException {
         var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
                 .setType(SignalServiceProtos.SyncMessage.Request.Type.CONFIGURATION)
                 .build();
@@ -1232,7 +1248,7 @@ public class Manager implements Closeable {
         }
     }
 
-    void requestSyncKeys() throws IOException {
+    private void requestSyncKeys() throws IOException {
         var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
                 .setType(SignalServiceProtos.SyncMessage.Request.Type.KEYS)
                 .build();