mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +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();
|
final var profile = profileAndCredential.getProfile();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
account.getIdentityKeyStore()
|
var newIdentity = account.getIdentityKeyStore()
|
||||||
.saveIdentity(recipientId,
|
.saveIdentity(recipientId,
|
||||||
new IdentityKey(Base64.getDecoder().decode(profile.getIdentityKey())),
|
new IdentityKey(Base64.getDecoder().decode(profile.getIdentityKey())),
|
||||||
new Date());
|
new Date());
|
||||||
|
|
||||||
|
if (newIdentity) {
|
||||||
|
account.getSessionStore().archiveSessions(recipientId);
|
||||||
|
}
|
||||||
} catch (InvalidKeyException ignored) {
|
} catch (InvalidKeyException ignored) {
|
||||||
logger.warn("Got invalid identity key in profile for {}",
|
logger.warn("Got invalid identity key in profile for {}",
|
||||||
resolveSignalServiceAddress(recipientId).getLegacyIdentifier());
|
resolveSignalServiceAddress(recipientId).getLegacyIdentifier());
|
||||||
|
@ -1363,10 +1367,12 @@ public class Manager implements Closeable {
|
||||||
|
|
||||||
for (var r : result) {
|
for (var r : result) {
|
||||||
if (r.getIdentityFailure() != null) {
|
if (r.getIdentityFailure() != null) {
|
||||||
account.getIdentityKeyStore().
|
final var recipientId = resolveRecipient(r.getAddress());
|
||||||
saveIdentity(resolveRecipient(r.getAddress()),
|
final var newIdentity = account.getIdentityKeyStore()
|
||||||
r.getIdentityFailure().getIdentityKey(),
|
.saveIdentity(recipientId, r.getIdentityFailure().getIdentityKey(), new Date());
|
||||||
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) {
|
public void mergeRecipients(RecipientId recipientId, RecipientId toBeMergedRecipientId) {
|
||||||
synchronized (cachedSessions) {
|
synchronized (cachedSessions) {
|
||||||
final var otherHasSession = getKeysLocked(toBeMergedRecipientId).size() > 0;
|
final var otherHasSession = getKeysLocked(toBeMergedRecipientId).size() > 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue