refactor pr review

This commit is contained in:
Matus Kosut 2020-05-16 14:55:39 +02:00
parent 97631fbe06
commit 77e48bf041
3 changed files with 17 additions and 6 deletions

View file

@ -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).

View file

@ -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) {

View file

@ -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
*/