chibenwa commented on code in PR #2884:
URL: https://github.com/apache/james-project/pull/2884#discussion_r2609457920


##########
mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/DeleteMessageListener.java:
##########
@@ -270,11 +283,29 @@ private Mono<Void> 
handleMessageDeletion(CassandraMessageId messageId, MailboxId
                 .then(threadLookupDAO.deleteOneRow(threadId, messageId)));
     }
 
+    private Mono<Void> dispatchMessageContentDeletionEvent(MailboxId 
mailboxId, Username owner, MessageRepresentation message) {
+        return 
Mono.from(contentDeletionEventBus.dispatch(EventFactory.messageContentDeleted()
+            .randomEventId()
+            .user(owner)
+            .mailboxId(mailboxId)
+            .messageId(message.getMessageId())
+            .size(message.getSize())
+            .instant(message.getInternalDate().toInstant())
+            .hasAttachments(!message.getAttachments().isEmpty())
+            .headerBlobId(message.getHeaderId().asString())
+            .bodyBlobId(message.getBodyId().asString())
+            .build(),
+            ImmutableSet.of()));
+    }
+
     private Mono<Void> 
handleMessageDeletionAsPartOfMailboxDeletion(CassandraMessageId messageId, 
ThreadId threadId, CassandraId excludedId, Username owner) {
         return Mono.just(messageId)
             .filterWhen(id -> isReferenced(id, excludedId))
             .flatMap(id -> readMessage(id)
-                .flatMap(message -> 
Flux.fromIterable(deletionCallbackList).concatMap(callback -> 
callback.forMessage(message, excludedId, owner)).then().thenReturn(message))
+                .flatMap(message -> Flux.fromIterable(deletionCallbackList)
+                    .concatMap(callback -> callback.forMessage(message, 
excludedId, owner))
+                    .then(dispatchMessageContentDeletionEvent(excludedId, 
owner, message)

Review Comment:
   > Different DeletionCallback interface between Cassandra and Postgres 
implementations.
   
   IMO we can factorize it in mailbox-store?
   
   > Do we want to always bind the content deletion event bus, regardless of 
vault enabled?
   
   IMO yes
   
   I would however propose an optimisation on Rabbit group event bus side: 
publis if and only if we have group listener regitered. However if no group 
listeners are registered we can skip publishing in the first place.
   
   That way we avoid needless event publication without asking ourselves if we 
need or not the eventbus.
   
   Thoughts?



-- 
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