mirror of
https://github.com/aljazceru/signal-cli.git
synced 2025-12-19 07:04:21 +01:00
Contact config - message expiration time (#308)
Co-authored-by: Matus Kosut <matus.kosut@ntnu.no>
This commit is contained in:
@@ -3,6 +3,8 @@ package org.asamk.signal.commands;
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||
|
||||
@@ -15,6 +17,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("Set expiration time of messages (seconds)");
|
||||
subparser.help("Update the details of a given contact");
|
||||
}
|
||||
|
||||
@@ -30,8 +36,16 @@ public class UpdateContactCommand implements LocalCommand {
|
||||
|
||||
try {
|
||||
m.setContactName(number, name);
|
||||
|
||||
Integer expiration = ns.getInt("expiration");
|
||||
if (expiration != null) {
|
||||
m.setExpirationTimer(number, expiration);
|
||||
}
|
||||
} catch (InvalidNumberException e) {
|
||||
System.out.println("Invalid contact number: " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
System.err.println("Update contact error: " + e.getMessage());
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user