Skip to content

Commit 6401995

Browse files
chibenwaArsnael
authored andcommitted
[ENHANCEMENT] Allow disable threads
This changeset will not alter thread categorisation which works decently today but only thread presentation to the end user which is currently relying on search. As an operator I wishes to have a security trigger if things go blur.
1 parent 1d8efb7 commit 6401995

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraThreadIdGuessingAlgorithm.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
import reactor.core.publisher.Mono;
4949

5050
public class CassandraThreadIdGuessingAlgorithm implements ThreadIdGuessingAlgorithm {
51+
private static final boolean DISABLE_THREADS = Boolean.valueOf(System.getProperty("james.mailbox.threads.disable", "false"));
52+
5153
private final MailboxManager mailboxManager;
5254
private final CassandraThreadDAO threadDAO;
5355
private final CassandraThreadLookupDAO threadLookupDAO;
@@ -82,6 +84,10 @@ public Mono<ThreadId> guessThreadIdReactive(MessageId messageId, Optional<MimeMe
8284

8385
@Override
8486
public Flux<MessageId> getMessageIdsInThread(ThreadId threadId, MailboxSession session) {
87+
if (DISABLE_THREADS) {
88+
return Flux.just(threadId.getBaseMessageId());
89+
}
90+
8591
SearchQuery searchQuery = SearchQuery.builder()
8692
.andCriteria(SearchQuery.threadId(threadId))
8793
.sorts(new SearchQuery.Sort(SearchQuery.Sort.SortClause.Arrival, SearchQuery.Sort.Order.NATURAL))

mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/PostgresThreadIdGuessingAlgorithm.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
import reactor.core.publisher.Mono;
4545

4646
public class PostgresThreadIdGuessingAlgorithm implements ThreadIdGuessingAlgorithm {
47+
private static final boolean DISABLE_THREADS = Boolean.valueOf(System.getProperty("james.mailbox.threads.disable", "false"));
48+
4749
private final PostgresThreadDAO.Factory threadDAOFactory;
4850

4951
@Inject
@@ -76,6 +78,10 @@ public Mono<ThreadId> guessThreadIdReactive(MessageId messageId, Optional<MimeMe
7678

7779
@Override
7880
public Flux<MessageId> getMessageIdsInThread(ThreadId threadId, MailboxSession session) {
81+
if (DISABLE_THREADS) {
82+
return Flux.just(threadId.getBaseMessageId());
83+
}
84+
7985
PostgresThreadDAO threadDAO = threadDAOFactory.create(session.getUser().getDomainPart());
8086
return threadDAO.findMessageIds(threadId, session.getUser())
8187
.switchIfEmpty(Flux.error(new ThreadNotFoundException(threadId)));

0 commit comments

Comments
 (0)