Delete cached failed messages after 30 days

This commit is contained in:
AsamK 2021-08-26 15:26:25 +02:00
parent 8bc6c0abcb
commit 634437d22d

View file

@ -851,6 +851,11 @@ public class Manager implements Closeable {
try { try {
content = dependencies.getCipher().decrypt(envelope); content = dependencies.getCipher().decrypt(envelope);
} catch (ProtocolUntrustedIdentityException e) { } catch (ProtocolUntrustedIdentityException e) {
if (System.currentTimeMillis() - envelope.getServerDeliveredTimestamp() > 1000L * 60 * 60 * 24 * 30) {
// Envelope is more than a month old, cleaning up.
cachedMessage.delete();
return null;
}
if (!envelope.hasSource()) { if (!envelope.hasSource()) {
final var identifier = e.getSender(); final var identifier = e.getSender();
final var recipientId = resolveRecipient(identifier); final var recipientId = resolveRecipient(identifier);