Skip to content

Commit cde2e2f

Browse files
authored
Merge pull request #718 from apache/master
[pull] master from apache:master
2 parents f90e174 + 9245ea0 commit cde2e2f

4 files changed

Lines changed: 16 additions & 14 deletions

File tree

mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageIdManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.apache.james.mailbox.model.MailboxACL;
5656
import org.apache.james.mailbox.model.MailboxACL.Right;
5757
import org.apache.james.mailbox.model.MailboxId;
58+
import org.apache.james.mailbox.model.MailboxPath;
5859
import org.apache.james.mailbox.model.MessageId;
5960
import org.apache.james.mailbox.model.MessageMetaData;
6061
import org.apache.james.mailbox.model.MessageMoves;
@@ -332,6 +333,10 @@ public Mono<Void> setInMailboxesReactive(MessageId messageId, Collection<Mailbox
332333
LOGGER.info("Tried to access {} not accessible for {}", messageId, mailboxSession.getUser().asString());
333334
return Mono.empty();
334335
}
336+
if (refined.getPreviousMailboxes().isEmpty()) {
337+
MailboxPath unreadablePreviousMailbox = messageMove.getPreviousMailboxes().iterator().next().generateAssociatedPath();
338+
return Mono.error(() -> new MailboxNotFoundException(unreadablePreviousMailbox));
339+
}
335340
if (refined.isChange()) {
336341
return applyMessageMoves(mailboxSession, currentMailboxMessages, refined);
337342
}

mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerStorageTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,15 +714,15 @@ void setInMailboxesShouldDenyCopyingMessageFromNotReadSharedMailbox() throws Exc
714714
MailboxACL.EMPTY.apply(
715715
MailboxACL.command()
716716
.forUser(BOB)
717-
.rights(Rfc4314Rights.allExcept(Right.Read))
717+
.rights(Rfc4314Rights.allExcept(Right.Read)) // the shared mailbox does not share the Read right for Bob
718718
.asAddition()),
719719
aliceSession);
720720
MessageId messageId = testingData.persist(aliceMailbox1.getMailboxId(), messageUid1, FLAGS, aliceSession);
721721

722-
//When
722+
// When Bob copies the message from the Alice's shared mailbox to Bob's mailbox, it should fail
723723
assertThatThrownBy(() ->
724724
messageIdManager.setInMailboxes(messageId,
725-
ImmutableList.of(aliceMailbox1.getMailboxId(), bobMailbox1.getMailboxId()),
725+
ImmutableList.of(bobMailbox1.getMailboxId()),
726726
bobSession))
727727
.isInstanceOf(MailboxNotFoundException.class);
728728

server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSetMethodContract.scala

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6495,23 +6495,20 @@ trait EmailSetMethodContract {
64956495
def emailSetDestroyShouldDestroyEmailWhenMovedIntoAnotherMailbox(server: GuiceJamesServer): Unit = {
64966496
val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
64976497

6498-
val andreMailbox: String = "andrecustom"
6499-
val andrePath = MailboxPath.forUser(ANDRE, andreMailbox)
6500-
val bobPath = MailboxPath.inbox(BOB)
6501-
mailboxProbe.createMailbox(andrePath)
6502-
val mailboxId: MailboxId = mailboxProbe.createMailbox(bobPath)
6498+
val mailbox: String = "custom"
6499+
val anotherMailbox: String = "anotherCustom"
6500+
mailboxProbe.createMailbox(MailboxPath.forUser(BOB, mailbox))
6501+
val anotherMailboxId = mailboxProbe.createMailbox(MailboxPath.forUser(BOB, anotherMailbox))
65036502

65046503
val messageId: MessageId = mailboxProbe
6505-
.appendMessage(ANDRE.asString, andrePath,
6504+
.appendMessage(BOB.asString, MailboxPath.forUser(BOB, mailbox),
65066505
AppendCommand.from(
65076506
buildTestMessage))
65086507
.getMessageId
65096508

6510-
server.getProbe(classOf[ACLProbeImpl])
6511-
.replaceRights(andrePath, BOB.asString, new MailboxACL.Rfc4314Rights(Right.Insert))
6512-
6509+
// Move message from mailbox to anotherMailbox
65136510
server.getProbe(classOf[JmapGuiceProbe])
6514-
.setInMailboxes(messageId, BOB, mailboxId)
6511+
.setInMailboxes(messageId, BOB, anotherMailboxId)
65156512

65166513
val request =
65176514
s"""{

server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryEmailSetMethodTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
public class MemoryEmailSetMethodTest extends MemoryBase implements EmailSetMethodContract {
2929
@Override
3030
public MessageId randomMessageId() {
31-
return InMemoryMessageId.of(ThreadLocalRandom.current().nextInt(100000) + 100);
31+
return InMemoryMessageId.of(ThreadLocalRandom.current().nextInt(1000000) + 100);
3232
}
3333

3434
@Override

0 commit comments

Comments
 (0)