mirror of
https://github.com/aljazceru/signal-cli.git
synced 2025-12-18 22:54:20 +01:00
Add commands to update contact names on Signal servers
As Signal Desktop does not allow its users to update the contact names, it would be nice to be able to update contact names from signal-cli when the latter is the master device. The command `setContactName` allow to set the name for the given contact in the local store. `sendContacts` can then be used to push the updated contact list on Signal servers. Closes #228
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package org.asamk.signal.commands;
|
||||
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class SendContactsCommand implements LocalCommand {
|
||||
|
||||
@Override
|
||||
public void attachToSubparser(final Subparser subparser) {
|
||||
subparser.help("Send contacts to the signal server.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int handleCommand(final Namespace ns, final Manager m) {
|
||||
if (!m.isRegistered()) {
|
||||
System.err.println("User is not registered.");
|
||||
return 1;
|
||||
}
|
||||
try {
|
||||
m.sendContacts();
|
||||
return 0;
|
||||
} catch (IOException | UntrustedIdentityException e) {
|
||||
System.err.println("SendContacts error: " + e.getMessage());
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user