You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by "vttranlina (via GitHub)" <gi...@apache.org> on 2023/09/27 02:26:48 UTC
[GitHub] [james-project] vttranlina commented on a diff in pull request #1740: [WIP] OpenSearch search index: upon move, GET then INDEX
vttranlina commented on code in PR #1740:
URL: https://github.com/apache/james-project/pull/1740#discussion_r1337971165
##########
mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/events/OpenSearchListeningMessageSearchIndex.java:
##########
@@ -131,7 +142,61 @@ public EnumSet<SearchCapabilities> getSupportedCapabilities(EnumSet<MessageCapab
SearchCapabilities.AttachmentFileName,
SearchCapabilities.PartialEmailMatch);
}
-
+
+ @Override
+ public Mono<Void> reactiveEvent(Event event) {
+ MailboxSession systemSession = sessionProvider.createSystemSession(event.getUsername());
+ return handleMailboxEvent(event, systemSession, (MailboxEvents.MailboxEvent) event)
+ .then(Mono.fromRunnable(() -> factory.endProcessingRequest(systemSession)));
+ }
+
+ private Mono<Void> handleMailboxEvent(Event event, MailboxSession session, MailboxEvents.MailboxEvent mailboxEvent) {
+ MailboxId mailboxId = mailboxEvent.getMailboxId();
+
+ if (event instanceof MailboxEvents.Added) {
+ MailboxEvents.Added addedEvent = (MailboxEvents.Added) event;
+
+ if (addedEvent.isMoved()) {
+ MailboxId movedFromMailboxId = addedEvent.movedFromMailboxId().get();
+ return Flux.fromIterable(addedEvent.getUids())
+ .concatMap(messageUid -> addByIndexedDocument(movedFromMailboxId, addedEvent.getMailboxId(), messageUid))
+ .onErrorResume(OpenSearchNotFoundException.class,
+ e -> addByFetchMailboxMessage((MailboxEvents.Added) event, session, mailboxId))
+ .then();
+ } else {
+ return addByFetchMailboxMessage((MailboxEvents.Added) event, session, mailboxId);
+ }
+ } else if (event instanceof MailboxEvents.Expunged) {
+ MailboxEvents.Expunged expunged = (MailboxEvents.Expunged) event;
+
+ return delete(session, mailboxId, expunged.getUids());
Review Comment:
because we still need to create a new document and remove an old document.
=> The ignore delete when `isMoved` is not the correct way
--
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: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org