mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 04:20:38 +00:00
refactor pr review
This commit is contained in:
parent
97631fbe06
commit
77e48bf041
3 changed files with 17 additions and 6 deletions
|
@ -252,6 +252,10 @@ Specify the contact phone number.
|
|||
*-n*, *--name*::
|
||||
Specify the new name for this contact.
|
||||
|
||||
*-e*, *--expiration*::
|
||||
Set expiration time of messages (seconds).
|
||||
By default expiration is set to 0, no expiration.
|
||||
|
||||
=== block
|
||||
|
||||
Block the given contacts or groups (no messages will be received).
|
||||
|
|
|
@ -18,7 +18,7 @@ public class UpdateContactCommand implements LocalCommand {
|
|||
subparser.addArgument("-e", "--expiration")
|
||||
.required(false)
|
||||
.type(int.class)
|
||||
.help("Specify expiration time of messages");
|
||||
.help("Set expiration time of messages (seconds)");
|
||||
subparser.help("Update the details of a given contact");
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,8 @@ public class UpdateContactCommand implements LocalCommand {
|
|||
try {
|
||||
m.setContactName(number, name);
|
||||
|
||||
int expiration = 0;
|
||||
if (ns.getInt("expiration") != null) {
|
||||
expiration = ns.getInt("expiration");
|
||||
Integer expiration = ns.getInt("expiration");
|
||||
if (expiration != null) {
|
||||
m.setExpirationTimer(number, expiration);
|
||||
}
|
||||
} catch (InvalidNumberException e) {
|
||||
|
|
|
@ -810,13 +810,21 @@ public class Manager implements Signal, Closeable {
|
|||
/**
|
||||
* Change the expiration timer for a contact
|
||||
*/
|
||||
public void setExpirationTimer(String number, int messageExpirationTimer) throws InvalidNumberException {
|
||||
ContactInfo c = account.getContactStore().getContact(canonicalizeAndResolveSignalServiceAddress(number));
|
||||
public void setExpirationTimer(SignalServiceAddress address, int messageExpirationTimer) {
|
||||
ContactInfo c = account.getContactStore().getContact(address);
|
||||
c.messageExpirationTime = messageExpirationTimer;
|
||||
account.getContactStore().updateContact(c);
|
||||
account.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the expiration timer for a contact
|
||||
*/
|
||||
public void setExpirationTimer(String number, int messageExpirationTimer) throws InvalidNumberException {
|
||||
SignalServiceAddress address = canonicalizeAndResolveSignalServiceAddress(number);
|
||||
setExpirationTimer(address, messageExpirationTimer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the expiration timer for a group
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue