Clean old prekeys only after server message queue is empty

This commit is contained in:
AsamK 2024-01-30 17:21:29 +01:00
parent d1e32f2b11
commit 080c14d111
3 changed files with 26 additions and 1 deletions

View file

@ -118,8 +118,15 @@ public class PreKeyHelper {
logger.warn("Failed to updated pre keys: {}", e.getMessage());
}
}
}
cleanSignedPreKeys((serviceIdType));
public void cleanOldPreKeys() {
cleanOldPreKeys(ServiceIdType.ACI);
cleanOldPreKeys(ServiceIdType.PNI);
}
private void cleanOldPreKeys(final ServiceIdType serviceIdType) {
cleanSignedPreKeys(serviceIdType);
cleanOneTimePreKeys(serviceIdType);
}

View file

@ -5,6 +5,7 @@ import org.asamk.signal.manager.actions.HandleAction;
import org.asamk.signal.manager.api.ReceiveConfig;
import org.asamk.signal.manager.api.UntrustedIdentityException;
import org.asamk.signal.manager.internal.SignalDependencies;
import org.asamk.signal.manager.jobs.CleanOldPreKeysJob;
import org.asamk.signal.manager.storage.SignalAccount;
import org.asamk.signal.manager.storage.messageCache.CachedMessage;
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
@ -176,6 +177,7 @@ public class ReceiveHelper {
handleQueuedActions(queuedActions.keySet());
queuedActions.clear();
context.getJobExecutor().enqueueJob(new CleanOldPreKeysJob());
hasCaughtUpWithOldMessages = true;
caughtUpWithOldMessagesListener.call();

View file

@ -0,0 +1,16 @@
package org.asamk.signal.manager.jobs;
import org.asamk.signal.manager.helper.Context;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CleanOldPreKeysJob implements Job {
private static final Logger logger = LoggerFactory.getLogger(CleanOldPreKeysJob.class);
@Override
public void run(Context context) {
logger.trace("Cleaning old prekeys");
context.getPreKeyHelper().cleanOldPreKeys();
}
}