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
|
@ -7,6 +7,7 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
|||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -30,16 +31,18 @@ public class UpdateContactCommand implements LocalCommand {
|
|||
var name = ns.getString("name");
|
||||
|
||||
try {
|
||||
m.setContactName(number, name);
|
||||
|
||||
var expiration = ns.getInt("expiration");
|
||||
if (expiration != null) {
|
||||
m.setExpirationTimer(number, expiration);
|
||||
}
|
||||
|
||||
m.setContactName(number, name);
|
||||
} catch (InvalidNumberException e) {
|
||||
throw new UserErrorException("Invalid contact number: " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
throw new IOErrorException("Update contact error: " + e.getMessage());
|
||||
} catch (NotMasterDeviceException e) {
|
||||
throw new UserErrorException("This command doesn't work on linked devices.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue