mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Add sendSyncRequest command
This commit is contained in:
parent
36475bb632
commit
9e3c9db5c0
4 changed files with 42 additions and 10 deletions
|
@ -1192,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()
|
var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
|
||||||
.setType(SignalServiceProtos.SyncMessage.Request.Type.GROUPS)
|
.setType(SignalServiceProtos.SyncMessage.Request.Type.GROUPS)
|
||||||
.build();
|
.build();
|
||||||
|
@ -1204,7 +1212,7 @@ public class Manager implements Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void requestSyncContacts() throws IOException {
|
private void requestSyncContacts() throws IOException {
|
||||||
var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
|
var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
|
||||||
.setType(SignalServiceProtos.SyncMessage.Request.Type.CONTACTS)
|
.setType(SignalServiceProtos.SyncMessage.Request.Type.CONTACTS)
|
||||||
.build();
|
.build();
|
||||||
|
@ -1216,7 +1224,7 @@ public class Manager implements Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void requestSyncBlocked() throws IOException {
|
private void requestSyncBlocked() throws IOException {
|
||||||
var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
|
var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
|
||||||
.setType(SignalServiceProtos.SyncMessage.Request.Type.BLOCKED)
|
.setType(SignalServiceProtos.SyncMessage.Request.Type.BLOCKED)
|
||||||
.build();
|
.build();
|
||||||
|
@ -1228,7 +1236,7 @@ public class Manager implements Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void requestSyncConfiguration() throws IOException {
|
private void requestSyncConfiguration() throws IOException {
|
||||||
var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
|
var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
|
||||||
.setType(SignalServiceProtos.SyncMessage.Request.Type.CONFIGURATION)
|
.setType(SignalServiceProtos.SyncMessage.Request.Type.CONFIGURATION)
|
||||||
.build();
|
.build();
|
||||||
|
@ -1240,7 +1248,7 @@ public class Manager implements Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void requestSyncKeys() throws IOException {
|
private void requestSyncKeys() throws IOException {
|
||||||
var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
|
var r = SignalServiceProtos.SyncMessage.Request.newBuilder()
|
||||||
.setType(SignalServiceProtos.SyncMessage.Request.Type.KEYS)
|
.setType(SignalServiceProtos.SyncMessage.Request.Type.KEYS)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -138,11 +138,7 @@ public class ProvisioningManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m.requestSyncGroups();
|
m.requestAllSyncData();
|
||||||
m.requestSyncContacts();
|
|
||||||
m.requestSyncBlocked();
|
|
||||||
m.requestSyncConfiguration();
|
|
||||||
m.requestSyncKeys();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Failed to request sync messages from linked device.");
|
logger.error("Failed to request sync messages from linked device.");
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class Commands {
|
||||||
addCommand("send", new SendCommand());
|
addCommand("send", new SendCommand());
|
||||||
addCommand("sendContacts", new SendContactsCommand());
|
addCommand("sendContacts", new SendContactsCommand());
|
||||||
addCommand("sendReaction", new SendReactionCommand());
|
addCommand("sendReaction", new SendReactionCommand());
|
||||||
|
addCommand("sendSyncRequest", new SendSyncRequestCommand());
|
||||||
addCommand("setPin", new SetPinCommand());
|
addCommand("setPin", new SetPinCommand());
|
||||||
addCommand("trust", new TrustCommand());
|
addCommand("trust", new TrustCommand());
|
||||||
addCommand("unblock", new UnblockCommand());
|
addCommand("unblock", new UnblockCommand());
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package org.asamk.signal.commands;
|
||||||
|
|
||||||
|
import net.sourceforge.argparse4j.inf.Namespace;
|
||||||
|
import net.sourceforge.argparse4j.inf.Subparser;
|
||||||
|
|
||||||
|
import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
|
import org.asamk.signal.manager.Manager;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class SendSyncRequestCommand implements LocalCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attachToSubparser(final Subparser subparser) {
|
||||||
|
subparser.help("Send a synchronization request message to master device (for group, contacts, ...).");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
|
||||||
|
try {
|
||||||
|
m.requestAllSyncData();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IOErrorException("Request sync data error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue