mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 12:30:39 +00:00
add message expiration time option to contactUpdate
This commit is contained in:
parent
87f65de0c5
commit
a52e3e635f
2 changed files with 14 additions and 2 deletions
|
@ -15,6 +15,10 @@ public class UpdateContactCommand implements LocalCommand {
|
||||||
subparser.addArgument("-n", "--name")
|
subparser.addArgument("-n", "--name")
|
||||||
.required(true)
|
.required(true)
|
||||||
.help("New contact name");
|
.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");
|
subparser.help("Update the details of a given contact");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +34,12 @@ public class UpdateContactCommand implements LocalCommand {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m.setContactName(number, name);
|
m.setContactName(number, name);
|
||||||
|
|
||||||
|
int expiration = 0;
|
||||||
|
if (ns.getInt("expiration") != null) {
|
||||||
|
expiration = ns.getInt("expiration");
|
||||||
|
m.setExpirationTimer(number, expiration);
|
||||||
|
}
|
||||||
} catch (InvalidNumberException e) {
|
} catch (InvalidNumberException e) {
|
||||||
System.out.println("Invalid contact number: " + e.getMessage());
|
System.out.println("Invalid contact number: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -810,10 +810,12 @@ public class Manager implements Signal {
|
||||||
/**
|
/**
|
||||||
* Change the expiration timer for a contact
|
* Change the expiration timer for a contact
|
||||||
*/
|
*/
|
||||||
public void setExpirationTimer(SignalServiceAddress address, int messageExpirationTimer) {
|
public void setExpirationTimer(String number, int messageExpirationTimer) throws InvalidNumberException {
|
||||||
ContactInfo c = account.getContactStore().getContact(address);
|
ContactInfo c = account.getContactStore().getContact(canonicalizeAndResolveSignalServiceAddress(number));
|
||||||
c.messageExpirationTime = messageExpirationTimer;
|
c.messageExpirationTime = messageExpirationTimer;
|
||||||
|
System.err.println("Set message expiration " + c.number + " -> " + c.messageExpirationTime + " seconds");
|
||||||
account.getContactStore().updateContact(c);
|
account.getContactStore().updateContact(c);
|
||||||
|
account.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue