This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 7215e1a9f284c7a51aab1631bbe3ff1fbbc6953a
Author: Benoit TELLIER <btell...@linagora.com>
AuthorDate: Wed Oct 9 22:13:26 2024 +0200

    JAMES-2182 Only user folder may be special use
---
 .../mpt/imapmailbox/suite/ListingWithSharingTest.java     |  2 ++
 .../apache/james/imap/scripts/ListWithSharedMailbox.test  | 15 +++++++++++++++
 .../james/imap/api/process/DefaultMailboxTyper.java       |  9 ++++++---
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git 
a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ListingWithSharingTest.java
 
b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ListingWithSharingTest.java
index c496b3724f..9273f41b2a 100644
--- 
a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ListingWithSharingTest.java
+++ 
b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ListingWithSharingTest.java
@@ -60,9 +60,11 @@ public abstract class ListingWithSharingTest implements 
ImapTestConstants {
             .withMailbox(OTHER_USER_SHARED_MAILBOX)
             .withMailbox(OTHER_USER_SHARED_MAILBOX_CHILD)
             .withMailbox(YET_ANOTHER_USER_SHARED_MAILBOX)
+            .withMailbox(MailboxPath.forUser(OTHER_USER_NAME, "Sent"))
             .withRights(OTHER_USER_SHARED_MAILBOX, USER, 
MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rl"))
             .withRights(OTHER_USER_SHARED_MAILBOX_CHILD, USER, 
MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rl"))
             .withRights(YET_ANOTHER_USER_SHARED_MAILBOX, USER, 
MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rl"))
+            .withRights(MailboxPath.forUser(OTHER_USER_NAME, "Sent"), USER, 
MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rl"))
             .withLocale(Locale.US)
             .run("ListWithSharedMailbox");
     }
diff --git 
a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ListWithSharedMailbox.test
 
b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ListWithSharedMailbox.test
index aecbbdad52..73214414b4 100644
--- 
a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ListWithSharedMailbox.test
+++ 
b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ListWithSharedMailbox.test
@@ -24,6 +24,7 @@ S: \* LIST \(\\HasNoChildren\) \"\.\" \"INBOX\"
 S: \* LIST \(\\HasNoChildren\) \".\" \"#user.diana.sharedMailbox\"
 S: \* LIST \(\\HasChildren\) \".\" \"#user.boby.sharedMailbox\"
 S: \* LIST \(\\HasNoChildren\) \".\" \"#user.boby.sharedMailbox.child\"
+S: \* LIST \(\\HasNoChildren\) \".\" \"#user.boby.Sent\"
 }
 S: a0 OK LIST completed.
 
@@ -38,6 +39,8 @@ S: \* LIST \(\\HasChildren\) \".\" 
\"#user.boby.sharedMailbox\"
 S: \* MYRIGHTS \"sharedMailbox\" \"lr\"
 S: \* LIST \(\\HasNoChildren\) \".\" \"#user.boby.sharedMailbox.child\"
 S: \* MYRIGHTS \"sharedMailbox.child\" \"lr\"
+S: \* LIST \(\\HasNoChildren\) \".\" \"#user.boby.Sent\"
+S: \* MYRIGHTS \"Sent\" \"lr\"
 }
 S: a1 OK LIST completed.
 
@@ -51,6 +54,8 @@ S: \* LIST \(\\HasChildren\) \".\" 
\"#user.boby.sharedMailbox\"
 S: \* STATUS \"#user.boby.sharedMailbox\" \(RECENT 0 UNSEEN 0\)
 S: \* LIST \(\\HasNoChildren\) \".\" \"#user.boby.sharedMailbox.child\"
 S: \* STATUS \"#user.boby.sharedMailbox.child\" \(RECENT 0 UNSEEN 0\)
+S: \* LIST \(\\HasNoChildren\) \".\" \"#user.boby.Sent\"
+S: \* STATUS \"#user.boby.Sent\" \(RECENT 0 UNSEEN 0\)
 }
 S: a2 OK LIST completed.
 
@@ -67,6 +72,7 @@ SUB {
 S: \* LIST \(\\HasNoChildren\) \".\" \"#user.diana.sharedMailbox\"
 S: \* LIST \(\\HasChildren\) \".\" \"#user.boby.sharedMailbox\"
 S: \* LIST \(\\HasNoChildren\) \".\" \"#user.boby.sharedMailbox.child\"
+S: \* LIST \(\\HasNoChildren\) \".\" \"#user.boby.Sent\"
 }
 S: a7 OK LIST completed.
 
@@ -85,3 +91,12 @@ S: a10 OK LIST completed.
 C: a11 LIST "#user" "diana."
 S: a11 OK LIST completed.
 
+C: a12 LIST "" "*" RETURN (SPECIAL-USE)
+SUB {
+S: \* LIST \(\\HasNoChildren\) \"\.\" \"INBOX\"
+S: \* LIST \(\\HasNoChildren\) \".\" \"#user.diana.sharedMailbox\"
+S: \* LIST \(\\HasChildren\) \".\" \"#user.boby.sharedMailbox\"
+S: \* LIST \(\\HasNoChildren\) \".\" \"#user.boby.sharedMailbox.child\"
+S: \* LIST \(\\HasNoChildren\) \".\" \"#user.boby.Sent\"
+}
+S: a12 OK LIST completed.
\ No newline at end of file
diff --git 
a/protocols/imap/src/main/java/org/apache/james/imap/api/process/DefaultMailboxTyper.java
 
b/protocols/imap/src/main/java/org/apache/james/imap/api/process/DefaultMailboxTyper.java
index 3e68724157..4aefd0f395 100644
--- 
a/protocols/imap/src/main/java/org/apache/james/imap/api/process/DefaultMailboxTyper.java
+++ 
b/protocols/imap/src/main/java/org/apache/james/imap/api/process/DefaultMailboxTyper.java
@@ -43,9 +43,12 @@ public class DefaultMailboxTyper implements MailboxTyper {
 
     @Override
     public MailboxType getMailboxType(ImapSession session, MailboxPath path) {
-        return Role.from(path.getName())
-            .flatMap(this::asMailboxType)
-            .orElse(MailboxType.OTHER);
+        if (path.belongsTo(session.getMailboxSession())) {
+            return Role.from(path.getName())
+                .flatMap(this::asMailboxType)
+                .orElse(MailboxType.OTHER);
+        }
+        return MailboxType.OTHER;
     }
 
     private Optional<MailboxType> asMailboxType(Role role) {


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to