Arsnael commented on code in PR #2902:
URL: https://github.com/apache/james-project/pull/2902#discussion_r2681047132


##########
mailbox/plugin/deleted-messages-vault/src/main/java/org/apache/james/vault/blob/BlobStoreDeletedMessageVault.java:
##########
@@ -235,4 +240,30 @@ private Mono<Void> deleteBucketData(BucketName bucketName) 
{
         return Mono.from(blobStore.deleteBucket(bucketName))
             
.then(Mono.from(messageMetadataVault.removeMetadataRelatedToBucket(bucketName)));
     }
+
+    Mono<Void> deleteUserExpiredMessages(ZonedDateTime 
beginningOfRetentionPeriod) {
+        BucketName bucketName = 
BucketName.of(vaultConfiguration.getSingleBucketName());
+
+        return Flux.from(metricFactory.decoratePublisherWithTimerMetric(
+            DELETE_EXPIRED_MESSAGES_METRIC_NAME,
+            Flux.from(usersRepository.listReactive())
+                .flatMap(username -> 
Flux.from(messageMetadataVault.listMessages(bucketName, username))
+                    .filter(deletedMessage -> 
isMessageFullyExpired(beginningOfRetentionPeriod, deletedMessage))
+                    .flatMap(deletedMessage -> 
messageMetadataVault.remove(bucketName, username, 
deletedMessage.getDeletedMessage().getMessageId())))))
+            .then();
+    }
+
+
+
+    private boolean isMessageFullyExpired(ZonedDateTime 
beginningOfRetentionPeriod, DeletedMessageWithStorageInformation 
deletedMessage) {
+        BlobId blobId = deletedMessage.getStorageInformation().getBlobId();
+        Optional<ZonedDateTime> maybeEndDate = 
blobIdTimeGenerator.blobIdEndTime(blobId);
+
+        if (maybeEndDate.isEmpty()) {
+            LOGGER.error("Pattern used for blobId used in deletedMessageVault 
is invalid and end date cannot be parsed {}", blobId);

Review Comment:
   Seems it does. Is that really an issue though?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to