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


##########
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:
   Interesting suggestion. Let's see how it goes.



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