mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Archive recipient's sessions after identity key switch
This commit is contained in:
parent
57617accb2
commit
5427fa0132
2 changed files with 19 additions and 5 deletions
|
@ -601,10 +601,14 @@ public class Manager implements Closeable {
|
|||
final var profile = profileAndCredential.getProfile();
|
||||
|
||||
try {
|
||||
account.getIdentityKeyStore()
|
||||
var newIdentity = account.getIdentityKeyStore()
|
||||
.saveIdentity(recipientId,
|
||||
new IdentityKey(Base64.getDecoder().decode(profile.getIdentityKey())),
|
||||
new Date());
|
||||
|
||||
if (newIdentity) {
|
||||
account.getSessionStore().archiveSessions(recipientId);
|
||||
}
|
||||
} catch (InvalidKeyException ignored) {
|
||||
logger.warn("Got invalid identity key in profile for {}",
|
||||
resolveSignalServiceAddress(recipientId).getLegacyIdentifier());
|
||||
|
@ -1363,10 +1367,12 @@ public class Manager implements Closeable {
|
|||
|
||||
for (var r : result) {
|
||||
if (r.getIdentityFailure() != null) {
|
||||
account.getIdentityKeyStore().
|
||||
saveIdentity(resolveRecipient(r.getAddress()),
|
||||
r.getIdentityFailure().getIdentityKey(),
|
||||
new Date());
|
||||
final var recipientId = resolveRecipient(r.getAddress());
|
||||
final var newIdentity = account.getIdentityKeyStore()
|
||||
.saveIdentity(recipientId, r.getIdentityFailure().getIdentityKey(), new Date());
|
||||
if (newIdentity) {
|
||||
account.getSessionStore().archiveSessions(recipientId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,6 +133,14 @@ public class SessionStore implements SignalServiceSessionStore {
|
|||
}
|
||||
}
|
||||
|
||||
public void archiveSessions(final RecipientId recipientId) {
|
||||
synchronized (cachedSessions) {
|
||||
getKeysLocked().stream()
|
||||
.filter(key -> key.recipientId.equals(recipientId))
|
||||
.forEach(this::archiveSessionLocked);
|
||||
}
|
||||
}
|
||||
|
||||
public void mergeRecipients(RecipientId recipientId, RecipientId toBeMergedRecipientId) {
|
||||
synchronized (cachedSessions) {
|
||||
final var otherHasSession = getKeysLocked(toBeMergedRecipientId).size() > 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue