quantranhong1999 commented on code in PR #2781:
URL: https://github.com/apache/james-project/pull/2781#discussion_r2241436010
##########
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/SessionSupplier.scala:
##########
@@ -40,28 +41,38 @@ class SessionSupplier(capabilityFactories:
Set[CapabilityFactory], configuration
.toOption
.getOrElse(false)
- def generate(username: Username, delegatedUsers: Set[Username], urlPrefixes:
UrlPrefixes): Either[IllegalArgumentException, Session] = {
+ def generate(username: Username, delegatedUsers: Set[Username], urlPrefixes:
UrlPrefixes): SMono[Session] = {
val urlEndpointResolver: JmapUrlEndpointResolver = new
JmapUrlEndpointResolver(urlPrefixes)
- val capabilities: Set[Capability] = capabilityFactories
- .map(cf => cf.create(urlPrefixes, username))
- .filter(capability =>
!configuration.disabledCapabilities.contains(capability.identifier()))
- for {
- account <- accounts(username, capabilities)
- delegatedAccounts <- delegatedAccounts(delegatedUsers, capabilities)
- } yield {
- Session(
- Capabilities(capabilities),
- List(account) ++ delegatedAccounts,
- primaryAccounts(account.accountId, capabilities),
- username,
- apiUrl = urlEndpointResolver.apiUrl,
- downloadUrl = urlEndpointResolver.downloadUrl,
- uploadUrl = urlEndpointResolver.uploadUrl,
- eventSourceUrl = urlEndpointResolver.eventSourceUrl)
- }
+ evaluateCapabilities(username, urlPrefixes)
+ .flatMap { capabilities =>
+ accounts(username, capabilities) match {
+ case Left(e) => SMono.error(e)
+ case Right(account) =>
+ delegatedAccounts(delegatedUsers, capabilities) match {
Review Comment:
Alright, it should look elegant now.
--
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]