Extract sending of expiration timer update to separate method

This commit is contained in:
AsamK 2020-05-22 12:48:39 +02:00
parent e048b1886d
commit 1aba9f370e

View file

@ -759,13 +759,16 @@ public class Manager implements Closeable {
* Change the expiration timer for a contact * Change the expiration timer for a contact
*/ */
public void setExpirationTimer(SignalServiceAddress address, int messageExpirationTimer) throws IOException { public void setExpirationTimer(SignalServiceAddress address, int messageExpirationTimer) throws IOException {
final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder();
ContactInfo contact = account.getContactStore().getContact(address); ContactInfo contact = account.getContactStore().getContact(address);
contact.messageExpirationTime = messageExpirationTimer; contact.messageExpirationTime = messageExpirationTimer;
account.getContactStore().updateContact(contact); account.getContactStore().updateContact(contact);
sendExpirationTimerUpdate(address);
account.save(); account.save();
messageBuilder.withExpiration(messageExpirationTimer); }
messageBuilder.asExpirationUpdate();
private void sendExpirationTimerUpdate(SignalServiceAddress address) throws IOException {
final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder()
.asExpirationUpdate();
sendMessage(messageBuilder, Collections.singleton(address)); sendMessage(messageBuilder, Collections.singleton(address));
} }