chibenwa commented on code in PR #3051:
URL: https://github.com/apache/james-project/pull/3051#discussion_r3308840397
##########
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/DownloadRoutes.scala:
##########
@@ -186,6 +197,17 @@ class UploadResolver @Inject()(val uploadService:
UploadService) extends BlobRes
}
}
}
+
+ override def validateAccess(blobId: BlobId, mailboxSession: MailboxSession):
SMono[java.lang.Boolean] =
+ if (!blobId.value.value.startsWith(prefix)) {
+ SMono.just(FALSE)
+ } else {
+ val uploadIdAsString = blobId.value.value.substring(prefix.length)
Review Comment:
`def asUploadId(blobId: BlobId): Option[UploadId]` for not to duplicate that
code ?
##########
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/DownloadRoutes.scala:
##########
@@ -201,6 +223,18 @@ class AttachmentBlobResolver @Inject()(val
attachmentManager: AttachmentManager,
}
case _ => SMono.just(NonApplicable)
}
+
+ override def validateAccess(blobId: BlobId, mailboxSession: MailboxSession):
SMono[java.lang.Boolean] =
+ Try(attachmentIdFactory.from(blobId.value.value)) match {
Review Comment:
`def asAttachmentId(blobId: BlobId): Option[AttachmentId]` ?
##########
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/DownloadRoutes.scala:
##########
@@ -165,6 +168,14 @@ class MessageBlobResolver @Inject()(val messageIdFactory:
MessageId.Factory,
.switchIfEmpty(SMono.just(NonApplicable))
}
}
+
+ override def validateAccess(blobId: BlobId, mailboxSession: MailboxSession):
SMono[java.lang.Boolean] =
+ Try(messageIdFactory.fromString(blobId.value.value)) match {
Review Comment:
To be consistent with other comments `def asMessageId(blobId: BlobId):
Option[MessageId]` ?
--
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]