Remove previous prekeys when importing legacy prekeys

This commit is contained in:
AsamK 2025-03-16 12:18:59 +01:00
parent 7aede7c17f
commit 2b150112ff

View file

@ -827,9 +827,9 @@ public class SignalAccount implements Closeable {
if (legacySignalProtocolStore != null && legacySignalProtocolStore.getLegacyPreKeyStore() != null) { if (legacySignalProtocolStore != null && legacySignalProtocolStore.getLegacyPreKeyStore() != null) {
logger.debug("Migrating legacy pre key store."); logger.debug("Migrating legacy pre key store.");
aciAccountData.getPreKeyStore().removeAllPreKeys();
for (var entry : legacySignalProtocolStore.getLegacyPreKeyStore().getPreKeys().entrySet()) { for (var entry : legacySignalProtocolStore.getLegacyPreKeyStore().getPreKeys().entrySet()) {
try { try {
aciAccountData.getPreKeyStore().removeAllPreKeys();
aciAccountData.getPreKeyStore().storePreKey(entry.getKey(), new PreKeyRecord(entry.getValue())); aciAccountData.getPreKeyStore().storePreKey(entry.getKey(), new PreKeyRecord(entry.getValue()));
} catch (InvalidMessageException e) { } catch (InvalidMessageException e) {
logger.warn("Failed to migrate pre key, ignoring", e); logger.warn("Failed to migrate pre key, ignoring", e);
@ -839,9 +839,9 @@ public class SignalAccount implements Closeable {
if (legacySignalProtocolStore != null && legacySignalProtocolStore.getLegacySignedPreKeyStore() != null) { if (legacySignalProtocolStore != null && legacySignalProtocolStore.getLegacySignedPreKeyStore() != null) {
logger.debug("Migrating legacy signed pre key store."); logger.debug("Migrating legacy signed pre key store.");
aciAccountData.getSignedPreKeyStore().removeAllSignedPreKeys();
for (var entry : legacySignalProtocolStore.getLegacySignedPreKeyStore().getSignedPreKeys().entrySet()) { for (var entry : legacySignalProtocolStore.getLegacySignedPreKeyStore().getSignedPreKeys().entrySet()) {
try { try {
aciAccountData.getSignedPreKeyStore().removeAllSignedPreKeys();
aciAccountData.getSignedPreKeyStore() aciAccountData.getSignedPreKeyStore()
.storeSignedPreKey(entry.getKey(), new SignedPreKeyRecord(entry.getValue())); .storeSignedPreKey(entry.getKey(), new SignedPreKeyRecord(entry.getValue()));
} catch (InvalidMessageException e) { } catch (InvalidMessageException e) {