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*::
|
*-n*, *--name*::
|
||||||
Specify the new name for this contact.
|
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
|
||||||
|
|
||||||
Block the given contacts or groups (no messages will be received).
|
Block the given contacts or groups (no messages will be received).
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class UpdateContactCommand implements LocalCommand {
|
||||||
subparser.addArgument("-e", "--expiration")
|
subparser.addArgument("-e", "--expiration")
|
||||||
.required(false)
|
.required(false)
|
||||||
.type(int.class)
|
.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");
|
subparser.help("Update the details of a given contact");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,8 @@ public class UpdateContactCommand implements LocalCommand {
|
||||||
try {
|
try {
|
||||||
m.setContactName(number, name);
|
m.setContactName(number, name);
|
||||||
|
|
||||||
int expiration = 0;
|
Integer expiration = ns.getInt("expiration");
|
||||||
if (ns.getInt("expiration") != null) {
|
if (expiration != null) {
|
||||||
expiration = ns.getInt("expiration");
|
|
||||||
m.setExpirationTimer(number, expiration);
|
m.setExpirationTimer(number, expiration);
|
||||||
}
|
}
|
||||||
} catch (InvalidNumberException e) {
|
} catch (InvalidNumberException e) {
|
||||||
|
|
|
@ -810,13 +810,21 @@ public class Manager implements Signal, Closeable {
|
||||||
/**
|
/**
|
||||||
* Change the expiration timer for a contact
|
* Change the expiration timer for a contact
|
||||||
*/
|
*/
|
||||||
public void setExpirationTimer(String number, int messageExpirationTimer) throws InvalidNumberException {
|
public void setExpirationTimer(SignalServiceAddress address, int messageExpirationTimer) {
|
||||||
ContactInfo c = account.getContactStore().getContact(canonicalizeAndResolveSignalServiceAddress(number));
|
ContactInfo c = account.getContactStore().getContact(address);
|
||||||
c.messageExpirationTime = messageExpirationTimer;
|
c.messageExpirationTime = messageExpirationTimer;
|
||||||
account.getContactStore().updateContact(c);
|
account.getContactStore().updateContact(c);
|
||||||
account.save();
|
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
|
* Change the expiration timer for a group
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue