This is an automated email from the ASF dual-hosted git repository.
hqtran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new 9245ea0058 [FIX] Correct `Right.read` check in
StoreMessageIdManager::setInMailboxesReactive (#2842)
9245ea0058 is described below
commit 9245ea005845e976afc78f1a08e06dfb4ae8e1c0
Author: Trần Hồng Quân <[email protected]>
AuthorDate: Fri Oct 31 08:13:15 2025 +0700
[FIX] Correct `Right.read` check in
StoreMessageIdManager::setInMailboxesReactive (#2842)
---
.../james/mailbox/store/StoreMessageIdManager.java | 5 +++++
.../store/AbstractMessageIdManagerStorageTest.java | 6 +++---
.../jmap/rfc8621/contract/EmailSetMethodContract.scala | 17 +++++++----------
.../jmap/rfc8621/memory/MemoryEmailSetMethodTest.java | 2 +-
4 files changed, 16 insertions(+), 14 deletions(-)
diff --git
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageIdManager.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageIdManager.java
index 49e23525a2..6a7187e15c 100644
---
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageIdManager.java
+++
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageIdManager.java
@@ -55,6 +55,7 @@ import org.apache.james.mailbox.model.Mailbox;
import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxACL.Right;
import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.model.MessageMetaData;
import org.apache.james.mailbox.model.MessageMoves;
@@ -332,6 +333,10 @@ public class StoreMessageIdManager implements
MessageIdManager {
LOGGER.info("Tried to access {} not accessible for
{}", messageId, mailboxSession.getUser().asString());
return Mono.empty();
}
+ if (refined.getPreviousMailboxes().isEmpty()) {
+ MailboxPath unreadablePreviousMailbox =
messageMove.getPreviousMailboxes().iterator().next().generateAssociatedPath();
+ return Mono.error(() -> new
MailboxNotFoundException(unreadablePreviousMailbox));
+ }
if (refined.isChange()) {
return applyMessageMoves(mailboxSession,
currentMailboxMessages, refined);
}
diff --git
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerStorageTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerStorageTest.java
index 92d568e7ae..c3d6aa6eda 100644
---
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerStorageTest.java
+++
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerStorageTest.java
@@ -714,15 +714,15 @@ public abstract class AbstractMessageIdManagerStorageTest
{
MailboxACL.EMPTY.apply(
MailboxACL.command()
.forUser(BOB)
- .rights(Rfc4314Rights.allExcept(Right.Read))
+ .rights(Rfc4314Rights.allExcept(Right.Read)) // the shared
mailbox does not share the Read right for Bob
.asAddition()),
aliceSession);
MessageId messageId =
testingData.persist(aliceMailbox1.getMailboxId(), messageUid1, FLAGS,
aliceSession);
- //When
+ // When Bob copies the message from the Alice's shared mailbox to
Bob's mailbox, it should fail
assertThatThrownBy(() ->
messageIdManager.setInMailboxes(messageId,
- ImmutableList.of(aliceMailbox1.getMailboxId(),
bobMailbox1.getMailboxId()),
+ ImmutableList.of(bobMailbox1.getMailboxId()),
bobSession))
.isInstanceOf(MailboxNotFoundException.class);
diff --git
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSetMethodContract.scala
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSetMethodContract.scala
index 9babd04add..69de5c929d 100644
---
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSetMethodContract.scala
+++
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSetMethodContract.scala
@@ -6495,23 +6495,20 @@ trait EmailSetMethodContract {
def emailSetDestroyShouldDestroyEmailWhenMovedIntoAnotherMailbox(server:
GuiceJamesServer): Unit = {
val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
- val andreMailbox: String = "andrecustom"
- val andrePath = MailboxPath.forUser(ANDRE, andreMailbox)
- val bobPath = MailboxPath.inbox(BOB)
- mailboxProbe.createMailbox(andrePath)
- val mailboxId: MailboxId = mailboxProbe.createMailbox(bobPath)
+ val mailbox: String = "custom"
+ val anotherMailbox: String = "anotherCustom"
+ mailboxProbe.createMailbox(MailboxPath.forUser(BOB, mailbox))
+ val anotherMailboxId = mailboxProbe.createMailbox(MailboxPath.forUser(BOB,
anotherMailbox))
val messageId: MessageId = mailboxProbe
- .appendMessage(ANDRE.asString, andrePath,
+ .appendMessage(BOB.asString, MailboxPath.forUser(BOB, mailbox),
AppendCommand.from(
buildTestMessage))
.getMessageId
- server.getProbe(classOf[ACLProbeImpl])
- .replaceRights(andrePath, BOB.asString, new
MailboxACL.Rfc4314Rights(Right.Insert))
-
+ // Move message from mailbox to anotherMailbox
server.getProbe(classOf[JmapGuiceProbe])
- .setInMailboxes(messageId, BOB, mailboxId)
+ .setInMailboxes(messageId, BOB, anotherMailboxId)
val request =
s"""{
diff --git
a/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryEmailSetMethodTest.java
b/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryEmailSetMethodTest.java
index 0bd25eee94..872e941170 100644
---
a/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryEmailSetMethodTest.java
+++
b/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryEmailSetMethodTest.java
@@ -28,7 +28,7 @@ import org.apache.james.mailbox.model.MessageId;
public class MemoryEmailSetMethodTest extends MemoryBase implements
EmailSetMethodContract {
@Override
public MessageId randomMessageId() {
- return
InMemoryMessageId.of(ThreadLocalRandom.current().nextInt(100000) + 100);
+ return
InMemoryMessageId.of(ThreadLocalRandom.current().nextInt(1000000) + 100);
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]