Contact config - message expiration time (#308)

Co-authored-by: Matus Kosut <matus.kosut@ntnu.no>
This commit is contained in:
Matúš Košút 2020-05-16 22:55:53 +02:00 committed by GitHub
parent 1e0aa8929d
commit b382a4260b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 4 deletions

View file

@ -758,10 +758,23 @@ public class Manager implements Closeable {
/**
* Change the expiration timer for a contact
*/
public void setExpirationTimer(SignalServiceAddress address, int messageExpirationTimer) {
ContactInfo c = account.getContactStore().getContact(address);
c.messageExpirationTime = messageExpirationTimer;
account.getContactStore().updateContact(c);
public void setExpirationTimer(SignalServiceAddress address, int messageExpirationTimer) throws IOException {
final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder();
ContactInfo contact = account.getContactStore().getContact(address);
contact.messageExpirationTime = messageExpirationTimer;
account.getContactStore().updateContact(contact);
account.save();
messageBuilder.withExpiration(messageExpirationTimer);
messageBuilder.asExpirationUpdate();
sendMessage(messageBuilder, Collections.singleton(address));
}
/**
* Change the expiration timer for a contact
*/
public void setExpirationTimer(String number, int messageExpirationTimer) throws IOException, InvalidNumberException {
SignalServiceAddress address = canonicalizeAndResolveSignalServiceAddress(number);
setExpirationTimer(address, messageExpirationTimer);
}
/**