quantranhong1999 commented on code in PR #2750:
URL: https://github.com/apache/james-project/pull/2750#discussion_r2161265303
##########
mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraThreadIdGuessingAlgorithm.java:
##########
@@ -88,17 +86,17 @@ public Flux<MessageId> getMessageIdsInThread(ThreadId
threadId, MailboxSession s
return Flux.just(threadId.getBaseMessageId());
}
- SearchQuery searchQuery = SearchQuery.builder()
- .andCriteria(SearchQuery.threadId(threadId))
- .sorts(new SearchQuery.Sort(SearchQuery.Sort.SortClause.Arrival,
SearchQuery.Sort.Order.NATURAL))
- .build();
-
- MultimailboxesSearchQuery expression = MultimailboxesSearchQuery
- .from(searchQuery)
- .build();
-
- return Flux.from(mailboxManager.search(expression, session,
Integer.MAX_VALUE))
- .switchIfEmpty(Mono.error(() -> new
ThreadNotFoundException(threadId)));
+ return threadLookupDAO.selectAll(threadId)
+ .collectList()
+ .map(ids -> {
+ // Handle umpopulated lookup dao
+ if (ids.isEmpty()) {
+ return ImmutableList.of(threadId.getBaseMessageId());
+ }
+ return ids;
+ })
+ .flatMapMany(messageIds ->
messageIdManager.accessibleMessagesReactive(messageIds, session))
Review Comment:
The test
`givenThreeMailsInAThreadThenGetThreadShouldReturnAListWithThreeMessageIdsSortedByArrivalDate`
is failing.
`messageIdManager.accessibleMessagesReactive` mixed the ordering (by date).
And I am not sure if `threadLookupDAO.selectAll(threadId)` keeps ordering
well too.
##########
mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraThreadIdGuessingAlgorithm.java:
##########
@@ -88,17 +86,17 @@ public Flux<MessageId> getMessageIdsInThread(ThreadId
threadId, MailboxSession s
return Flux.just(threadId.getBaseMessageId());
}
- SearchQuery searchQuery = SearchQuery.builder()
- .andCriteria(SearchQuery.threadId(threadId))
- .sorts(new SearchQuery.Sort(SearchQuery.Sort.SortClause.Arrival,
SearchQuery.Sort.Order.NATURAL))
- .build();
-
- MultimailboxesSearchQuery expression = MultimailboxesSearchQuery
- .from(searchQuery)
- .build();
-
- return Flux.from(mailboxManager.search(expression, session,
Integer.MAX_VALUE))
- .switchIfEmpty(Mono.error(() -> new
ThreadNotFoundException(threadId)));
+ return threadLookupDAO.selectAll(threadId)
+ .collectList()
+ .map(ids -> {
+ // Handle umpopulated lookup dao
+ if (ids.isEmpty()) {
+ return ImmutableList.of(threadId.getBaseMessageId());
Review Comment:
I am thinking about fallback to OpenSearch for this:
- Keep the thread working well for previous messages
- Fix the
`givenNonMailInAThreadThenGetThreadShouldThrowThreadNotFoundException` test:
actual not found thread should throw `ThreadNotFoundException`, not naive based
MessageId threadId.
--
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]