You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2023/03/17 22:10:24 UTC
[james-project] 01/02: JAMES-3854 [FIX] IMAP STATUS should allow fetching Deleted and Deleted-Storage individually
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit fdce761d2d98870014a348d1acb68223c8c9c6ce
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Mar 17 09:02:21 2023 +0700
JAMES-3854 [FIX] IMAP STATUS should allow fetching Deleted and Deleted-Storage individually
---
.../org/apache/james/imap/scripts/Status.test | 16 ++++++++++++----
.../apache/james/imap/processor/StatusProcessor.java | 18 +++++++++++++++---
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Status.test b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Status.test
index 89eb6f8640..a148eaaed4 100644
--- a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Status.test
+++ b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Status.test
@@ -122,18 +122,26 @@ C: A013 STATUS statustest (UNSEEN SIZE MESSAGES DELETED DELETED-STORAGE)
S: \* STATUS \"statustest\" \(MESSAGES 4 SIZE 1016 DELETED 2 DELETED-STORAGE 508 UNSEEN 4\)
S: A013 OK STATUS completed.
-C: a014 STATUS statustest (MAILBOXID)
+C: A014 STATUS statustest (DELETED)
+S: \* STATUS \"statustest\" \(DELETED 2\)
+S: A014 OK STATUS completed.
+
+C: A015 STATUS statustest (DELETED-STORAGE)
+S: \* STATUS \"statustest\" \(DELETED-STORAGE 508\)
+S: A015 OK STATUS completed.
+
+C: a016 STATUS statustest (MAILBOXID)
S: \* STATUS \"statustest\" \(MAILBOXID \(.+\)\)
-S: a014 OK STATUS completed.
+S: a016 OK STATUS completed.
-C: a015 LIST "" * RETURN (STATUS (UNSEEN SIZE MESSAGES DELETED DELETED-STORAGE MAILBOXID))
+C: a017 LIST "" * RETURN (STATUS (UNSEEN SIZE MESSAGES DELETED DELETED-STORAGE MAILBOXID))
SUB {
S: \* LIST \(\\HasNoChildren\) "." "INBOX"
S: \* STATUS \"INBOX\" \(MESSAGES 0 SIZE 0 DELETED 0 DELETED-STORAGE 0 UNSEEN 0 MAILBOXID \(.+\)\)
S: \* LIST \(\\HasNoChildren\) "." "statustest"
S: \* STATUS "statustest" \(MESSAGES 4 SIZE 1016 DELETED 2 DELETED-STORAGE 508 UNSEEN 4 MAILBOXID \(.+\)\)
}
-S: a015 OK LIST completed.
+S: a017 OK LIST completed.
# Cleanup
C: a1 DELETE statustest
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/StatusProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/StatusProcessor.java
index c8af849e96..97f8cedeb8 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/StatusProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/StatusProcessor.java
@@ -45,6 +45,7 @@ import org.apache.james.mailbox.MessageManager.MailboxMetaData.RecentMode;
import org.apache.james.mailbox.MessageUid;
import org.apache.james.mailbox.ModSeq;
import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.ComposedMessageIdWithMetaData;
import org.apache.james.mailbox.model.FetchGroup;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath;
@@ -254,13 +255,17 @@ public class StatusProcessor extends AbstractMailboxProcessor<StatusRequest> imp
}
private Mono<Optional<MailboxIterationResult>> iterateMailbox(StatusDataItems statusDataItems, MessageManager messageManager, MailboxSession session) {
- if (statusDataItems.isSize()) {
+ if (statusDataItems.isSize() || statusDataItems.isDeletedStorage()) {
return Flux.from(messageManager.getMessagesReactive(MessageRange.all(), FetchGroup.MINIMAL, session))
.reduce(new MailboxIterationResult(), MailboxIterationResult::accumulate)
.map(Optional::of);
- } else {
- return Mono.just(Optional.empty());
}
+ if (statusDataItems.isDeleted()) {
+ return Flux.from(messageManager.listMessagesMetadata(MessageRange.all(), session))
+ .reduce(new MailboxIterationResult(), MailboxIterationResult::accumulateDeleted)
+ .map(Optional::of);
+ }
+ return Mono.just(Optional.empty());
}
public static class MailboxIterationResult {
@@ -277,6 +282,13 @@ public class StatusProcessor extends AbstractMailboxProcessor<StatusRequest> imp
return this;
}
+ public MailboxIterationResult accumulateDeleted(ComposedMessageIdWithMetaData metaData) {
+ if (metaData.getFlags().contains(Flags.Flag.DELETED)) {
+ deleted++;
+ }
+ return this;
+ }
+
public Optional<Long> getSize(StatusDataItems items) {
if (items.isSize()) {
return Optional.of(size);
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org