/*
- Copyright (C) 2015-2021 AsamK and contributors
+ Copyright (C) 2015-2022 AsamK and contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import io.reactivex.rxjava3.disposables.CompositeDisposable;
+
public class ManagerImpl implements Manager {
private final static Logger logger = LoggerFactory.getLogger(ManagerImpl.class);
private final Set<ReceiveMessageHandler> weakHandlers = new HashSet<>();
private final Set<ReceiveMessageHandler> messageHandlers = new HashSet<>();
private final List<Runnable> closedListeners = new ArrayList<>();
+ private final CompositeDisposable disposable = new CompositeDisposable();
ManagerImpl(
SignalAccount account,
this.notifyAll();
}
});
+ disposable.add(account.getIdentityKeyStore().getIdentityChanges().subscribe(recipientId -> {
+ logger.trace("Archiving old sessions for {}", recipientId);
+ account.getSessionStore().archiveSessions(recipientId);
+ account.getSenderKeyStore().deleteSharedWith(recipientId);
+ final var profile = account.getRecipientStore().getProfile(recipientId);
+ if (profile != null) {
+ account.getRecipientStore()
+ .storeProfile(recipientId,
+ Profile.newBuilder(profile)
+ .withUnidentifiedAccessMode(Profile.UnidentifiedAccessMode.UNKNOWN)
+ .withLastUpdateTimestamp(0)
+ .build());
+ }
+ }));
}
@Override
}
@Override
- public void removeLinkedDevices(long deviceId) throws IOException {
+ public void removeLinkedDevices(int deviceId) throws IOException {
context.getAccountHelper().removeLinkedDevices(deviceId);
}
executor.shutdown();
dependencies.getSignalWebSocket().disconnect();
+ disposable.dispose();
synchronized (closedListeners) {
closedListeners.forEach(Runnable::run);