You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2022/10/11 02:51:00 UTC

[GitHub] [james-project] vttranlina commented on a diff in pull request #1242: JAMES-3830 Implement JMAP Quota/get

vttranlina commented on code in PR #1242:
URL: https://github.com/apache/james-project/pull/1242#discussion_r991768244


##########
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/Quotas.scala:
##########
@@ -59,4 +68,123 @@ case class Quota(quota: Map[Quotas.Type, Value]) extends AnyVal
 
 case class Value(used: UnsignedInt, max: Option[UnsignedInt])
 
-case class Quotas(quotas: Map[QuotaId, Quota]) extends AnyVal
\ No newline at end of file
+case class Quotas(quotas: Map[QuotaId, Quota]) extends AnyVal
+
+case class UnparsedQuotaId(id: Id)
+
+case class QuotaIds(value: List[UnparsedQuotaId])
+
+case class QuotaGetRequest(accountId: AccountId,
+                           ids: Option[QuotaIds],
+                           properties: Option[Properties]) extends WithAccountId
+
+object JmapQuota {
+
+  val allProperties: Properties = Properties("id", "resourceType", "used", "limit", "scope", "name", "dataTypes", "warnLimit", "softLimit", "description")
+  val idProperty: Properties = Properties("id")
+
+  def propertiesFiltered(requestedProperties: Properties) : Properties = idProperty ++ requestedProperties
+}
+
+
+case class JmapQuota(id: Id,
+                     resourceType: ResourceType,
+                     used: UnsignedInt,
+                     limit: UnsignedInt,
+                     scope: Scope,
+                     name: QuotaName,
+                     dataTypes: List[DataType],
+                     warnLimit: Option[UnsignedInt] = None,
+                     softLimit: Option[UnsignedInt] = None,
+                     description: Option[QuotaDescription] = None)
+
+object QuotaName {
+  def from(scope: Scope, resourceType: ResourceType, dataTypes: List[DataType]): QuotaName =
+    QuotaName(s"${scope.asString()}:${resourceType.asString()}:${dataTypes.map(_.asString()).mkString("_")}")
+}
+
+case class QuotaName(string: String)
+
+case class QuotaDescription(string: String)
+
+sealed trait ResourceType {
+  def asString(): String
+}
+
+case object CountResourceType extends ResourceType {
+  override def asString(): String = "count"
+}
+
+case object OctetsResourceType extends ResourceType {
+  override def asString(): String = "octets"
+}
+
+object Scope {
+  def fromJava(scope: org.apache.james.mailbox.model.Quota.Scope): Scope =
+    scope match {
+      case org.apache.james.mailbox.model.Quota.Scope.Domain => DomainScope
+      case org.apache.james.mailbox.model.Quota.Scope.Global => GlobalScope
+      case org.apache.james.mailbox.model.Quota.Scope.User => AccountScope
+    }
+}
+
+trait Scope {
+  def asString(): String
+
+}
+
+case object AccountScope extends Scope {
+  override def asString(): String = "account"
+}
+
+case object DomainScope extends Scope {
+  override def asString(): String = "domain"
+}
+
+case object GlobalScope extends Scope {
+  override def asString(): String = "global"
+}

Review Comment:
   > Then Quota/get should return a single quota with 5GB as a limit!
   
   Why do we return single 5GB? return Only User quota or return max limit?
   



-- 
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: notifications-unsubscribe@james.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org