quantranhong1999 commented on code in PR #2884:
URL: https://github.com/apache/james-project/pull/2884#discussion_r2609405998
##########
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:
> Event bus callback would then likely be reused as is for the PG codepath
Different `DeletionCallback` interface between Cassandra and Postgres
implementations. So it is not a drop in reusage.
I think the question should be more: Do we want to always bind the content
deletion event bus, regardless of vault enabled?
If we use the content deletion event bus directly in
`DeleteMessageListener`, we always bind the content deletion event bus (hence,
the event bus work queue is created, potentially without any real usage).
If we implement the dispatch as a callback, potentially we can plug it only
when the vault work queue is enabled? So we can use the event bus work queue
only when needed. However, if other listeners (e.g. `RagDeletionListener`) want
to subscribe to the content deletion event bus, it is not easy as it depends on
the vault usage.
I am not sure what the best way to go is. Maybe for James, we only bind the
content deletion event bus when vault work queue is enabled. For Tmail, we
always bind the content deletion event bus to ease the usage?
--
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]