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 e51887b4e7126c76e9a0b59dfac7e63d0cc3bf14 Author: Benoit Tellier <[email protected]> AuthorDate: Thu Oct 28 10:15:17 2021 +0700 JAMES-3539 Define PushTTL.MAX constant --- .../scala/org/apache/james/jmap/pushsubscription/PushRequest.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/pushsubscription/PushRequest.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/pushsubscription/PushRequest.scala index 4525344..511c68c 100644 --- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/pushsubscription/PushRequest.scala +++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/pushsubscription/PushRequest.scala @@ -71,15 +71,20 @@ object PushTopic { object PushTTL { type PushTTL = Long Refined PushTTLConstraint + private val MAX_INT = 2147483647L + implicit val validateTTL: Validate.Plain[Long, PushTTLConstraint] = - Validate.fromPredicate(s => s >= 0 && s < 2147483648L, + Validate.fromPredicate(s => s >= 0 && s <= MAX_INT, s => s"'$s' invalid. Should be non-negative numeric and no greater than 2^31", PushTTLConstraint()) + def validate(value: Long): Either[IllegalArgumentException, PushTTL] = refined.refineV[PushTTLConstraint](value) .left .map(new IllegalArgumentException(_)) + + val MAX: PushTTL = validate(MAX_INT).toOption.get } case class PushTopicConstraint() --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
