vttranlina commented on a change in pull request #716:
URL: https://github.com/apache/james-project/pull/716#discussion_r740720314
##########
File path:
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/PushSubscriptionSetCreatePerformer.scala
##########
@@ -87,3 +95,20 @@ class PushSubscriptionSetCreatePerformer
@Inject()(pushSubscriptionRepository: P
case (path, _) =>
SetError.invalidArguments(SetErrorDescription(s"Unknown error on property
'$path'"))
}
}
+
+object PushSubscriptionSetCreateProcessor {
Review comment:
I don't like this name, I used it because the issue wrote that
(https://github.com/linagora/james-project/issues/4411)
Should we rename it to "PushVerificationProcessor" ? or move it directly
inside the `PushSubscriptionSetCreatePerformer` class.
##########
File path:
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/PushSubscriptionSetCreatePerformer.scala
##########
@@ -70,6 +75,9 @@ class PushSubscriptionSetCreatePerformer
@Inject()(pushSubscriptionRepository: P
private def create(clientId: PushSubscriptionCreationId, request:
PushSubscriptionCreationRequest, mailboxSession: MailboxSession):
SMono[CreationResult] =
SMono.fromPublisher(pushSubscriptionRepository.save(mailboxSession.getUser,
request))
+ .flatMap(subscription =>
verificationCreateProcessor.pushVerificationToPushServer(subscription.url,
Review comment:
Should we handler the `pushVerificationToPushServer` error case? Then we
will remove the entry saved before?
##########
File path:
server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/PushSubscriptionSetMethodContract.scala
##########
@@ -820,4 +836,100 @@ trait PushSubscriptionSetMethodContract {
| ]
|}""".stripMargin)
}
+
+ @Test
+ def setMethodCreateShouldCallVerificationToPushServer(pushServer:
ClientAndServer): Unit = {
+ val request: String =
+ s"""{
+ | "using": ["urn:ietf:params:jmap:core"],
+ | "methodCalls": [
+ | [
+ | "PushSubscription/set",
+ | {
+ | "create": {
+ | "4f29": {
+ | "deviceClientId": "a889-ffea-910",
+ | "url": "${getPushServerUrl(pushServer)}",
+ | "types": ["Mailbox"]
+ | }
+ | }
+ | },
+ | "c1"
+ | ]
+ | ]
+ | }""".stripMargin
+
+ `given`
+ .body(request)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+
+ pushServer.verify(HttpRequest.request()
+ .withPath("/subscribe"),
Review comment:
For validate body request, It already at
`org.apache.james.jmap.pushsubscription.PushSubscriptionSetCreateProcessorTest#pushVerificationShouldSuccess`
In `PushSubscriptionSetMethodContract`, we don't have a guiceProbe (or
something) for get "verificationCode".
##########
File path:
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/PushSubscriptionSetCreatePerformer.scala
##########
@@ -87,3 +95,20 @@ class PushSubscriptionSetCreatePerformer
@Inject()(pushSubscriptionRepository: P
case (path, _) =>
SetError.invalidArguments(SetErrorDescription(s"Unknown error on property
'$path'"))
}
}
+
+object PushSubscriptionSetCreateProcessor {
+ val PUSH_VERIFICATION_TO_PUSH_SERVER_TTL_DEFAULT: PushTTL =
PushTTL.validate(15).toOption.get
Review comment:
your mean is `PushTTL.MAX`?
##########
File path:
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/PushSubscriptionSetCreatePerformer.scala
##########
@@ -87,3 +95,20 @@ class PushSubscriptionSetCreatePerformer
@Inject()(pushSubscriptionRepository: P
case (path, _) =>
SetError.invalidArguments(SetErrorDescription(s"Unknown error on property
'$path'"))
}
}
+
+object PushSubscriptionSetCreateProcessor {
Review comment:
I don't like this name, I used it because the issue wrote that
(https://github.com/linagora/james-project/issues/4411)
Should we rename it to "PushVerificationProcessor" ? or move it directly
inside the `PushSubscriptionSetCreatePerformer` class.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]