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


##########
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:
   Or even...
   
   Just keeping the current implementation.
   
   But we fully remove deletion callbacks. 
   
   Rational:
    - unsafe to use
    - relevant implems use a safer listener based implementation 
    - drop one interface 
    - no longer manual plugging into MessageManager
   
   This would be a major code simplification that definitely looks worth it.
   
   Tldr: I would like us to explore this refactoring further!
   
   Delete listener just ALWAYS publish to the event bus (with aforementioned 
optim) and we drop deletion callbacks.



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