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 2021/11/22 11:04:55 UTC

[GitHub] [james-project] vttranlina commented on a change in pull request #757: [WIP] JAMES-3534 Identity/set update should work on existing server-set Identities

vttranlina commented on a change in pull request #757:
URL: https://github.com/apache/james-project/pull/757#discussion_r754164824



##########
File path: server/data/data-jmap/src/main/scala/org/apache/james/jmap/api/identity/CustomIdentityDAO.scala
##########
@@ -120,15 +131,42 @@ class IdentityRepository @Inject()(customIdentityDao: CustomIdentityDAO, identit
       SMono.error(ForbiddenSendFromException(creationRequest.email))
     }
 
-  def list(user: Username): Publisher[Identity] = SFlux.merge(Seq(
-    customIdentityDao.list(user),
-    SMono.fromCallable(() => identityFactory.listIdentities(user))
-      .subscribeOn(Schedulers.elastic())
-      .flatMapMany(SFlux.fromIterable)))
+  def list(user: Username): Publisher[Identity] = {
+    val customIdentities: SFlux[(String, Identity)] = SFlux.fromPublisher(customIdentityDao.list(user))
+      .map(e=> (IdentityOrigin.CUSTOM, e))
 
-  def update(user: Username, identityId: IdentityId, identityUpdate: IdentityUpdate): Publisher[Unit] = customIdentityDao.update(user, identityId, identityUpdate)
+    val serverSetIdentities: SFlux[(String, Identity)] = SMono.fromCallable(() => identityFactory.listIdentities(user))
+      .subscribeOn(Schedulers.elastic())
+      .flatMapMany(SFlux.fromIterable)
+      .map(e=> (IdentityOrigin.SERVER_SET, e))
+
+    SFlux.merge(Seq(customIdentities, serverSetIdentities))
+      .groupBy(_._2.id)

Review comment:
       The `groupBy` will block reactive. But the total number of identities for each account will not too large. 
   Should it ok? 




-- 
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