add message expiration time option to contactUpdate

This commit is contained in:
Matus Kosut 2020-05-14 17:33:31 +02:00
parent 87f65de0c5
commit a52e3e635f
2 changed files with 14 additions and 2 deletions

View file

@ -15,6 +15,10 @@ public class UpdateContactCommand implements LocalCommand {
subparser.addArgument("-n", "--name")
.required(true)
.help("New contact name");
subparser.addArgument("-e", "--expiration")
.required(false)
.type(int.class)
.help("Specify expiration time of messages");
subparser.help("Update the details of a given contact");
}
@ -30,6 +34,12 @@ public class UpdateContactCommand implements LocalCommand {
try {
m.setContactName(number, name);
int expiration = 0;
if (ns.getInt("expiration") != null) {
expiration = ns.getInt("expiration");
m.setExpirationTimer(number, expiration);
}
} catch (InvalidNumberException e) {
System.out.println("Invalid contact number: " + e.getMessage());
}

View file

@ -810,10 +810,12 @@ public class Manager implements Signal {
/**
* Change the expiration timer for a contact
*/
public void setExpirationTimer(SignalServiceAddress address, int messageExpirationTimer) {
ContactInfo c = account.getContactStore().getContact(address);
public void setExpirationTimer(String number, int messageExpirationTimer) throws InvalidNumberException {
ContactInfo c = account.getContactStore().getContact(canonicalizeAndResolveSignalServiceAddress(number));
c.messageExpirationTime = messageExpirationTimer;
System.err.println("Set message expiration " + c.number + " -> " + c.messageExpirationTime + " seconds");
account.getContactStore().updateContact(c);
account.save();
}
/**