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 4d0a14f9540b70f57160628b282c0634674ae1b4 Author: Benoit Tellier <btell...@linagora.com> AuthorDate: Fri Aug 14 11:59:19 2020 +0700 JAMES-3357 Mailbox/set destroy should handle isSubscribed --- .../contract/MailboxSetMethodContract.scala | 45 ++++++++++++++++++++++ .../james/jmap/method/MailboxSetMethod.scala | 7 ++-- 2 files changed, 49 insertions(+), 3 deletions(-) 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/MailboxSetMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala index 073b482..bf6c8aa 100644 --- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala +++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala @@ -495,6 +495,51 @@ trait MailboxSetMethodContract { } @Test + def destroyShouldUnsubscribeMailboxes(server: GuiceJamesServer): Unit = { + val request= + """ + |{ + | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail" ], + | "methodCalls": [ + | ["Mailbox/set", + | { + | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6", + | "create": { + | "C42": { + | "name": "myMailbox" + | } + | } + | }, + | "c1"], + | [ + | "Mailbox/set", + | { + | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6", + | "destroy": ["#C42"] + | }, + | "c2"] + | ] + |} + |""".stripMargin + + `given` + .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER) + .body(request) + .when + .post + .`then` + .log().ifValidationFails() + .statusCode(SC_OK) + .contentType(JSON) + .extract + .body + .asString + + Assertions.assertThat(server.getProbe(classOf[MailboxProbeImpl]) + .listSubscriptions(BOB.asString())).doesNotContain("myMailbox") + } + + @Test def mailboxSetShouldReturnCreatedWhenOnlyName(server: GuiceJamesServer): Unit = { val request = """ diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala index 9aa20b4..3c7470c 100644 --- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala +++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala @@ -29,7 +29,7 @@ import org.apache.james.jmap.model.Invocation.{Arguments, MethodName} import org.apache.james.jmap.model.{ClientId, Id, Invocation, ServerId, State} import org.apache.james.jmap.routes.ProcessingContext import org.apache.james.mailbox.exception.{InsufficientRightsException, MailboxExistsException, MailboxNameException, MailboxNotFoundException} -import org.apache.james.mailbox.model.{FetchGroup, Mailbox, MailboxId, MailboxPath, MessageRange} +import org.apache.james.mailbox.model.{FetchGroup, MailboxId, MailboxPath, MessageRange} import org.apache.james.mailbox.{MailboxManager, MailboxSession, SubscriptionManager} import org.apache.james.metrics.api.MetricFactory import org.reactivestreams.Publisher @@ -146,7 +146,7 @@ class MailboxSetMethod @Inject()(serializer: Serializer, } } - private def delete(mailboxSession: MailboxSession, id: MailboxId): Mailbox = { + private def delete(mailboxSession: MailboxSession, id: MailboxId): Unit = { val mailbox = mailboxManager.getMailbox(id, mailboxSession) if (mailbox.getMessages(MessageRange.all(), FetchGroup.MINIMAL, mailboxSession).hasNext) { throw MailboxHasMailException(id) @@ -154,7 +154,8 @@ class MailboxSetMethod @Inject()(serializer: Serializer, if (mailboxManager.hasChildren(mailbox.getMailboxPath, mailboxSession)) { throw MailboxHasChildException(id) } - mailboxManager.deleteMailbox(id, mailboxSession) + val deletedMailbox = mailboxManager.deleteMailbox(id, mailboxSession) + subscriptionManager.unsubscribe(mailboxSession, deletedMailbox.getName) } private def createMailboxes(mailboxSession: MailboxSession, --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org