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 2023/01/05 01:56:20 UTC

[GitHub] [james-project] chibenwa commented on a diff in pull request #1372: JAMES-3756 Delegation store should allow listing accounts delegated to me

chibenwa commented on code in PR #1372:
URL: https://github.com/apache/james-project/pull/1372#discussion_r1062034561


##########
server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraDelegationStore.java:
##########
@@ -40,16 +46,31 @@ public Publisher<Username> authorizedUsers(Username baseUser) {
 
     @Override
     public Publisher<Void> clear(Username baseUser) {
-        return cassandraUsersDAO.removeAllAuthorizedUsers(baseUser);
+        return cassandraUsersDAO.getAuthorizedUsers(baseUser)
+            .flatMap(authorizedUser -> cassandraUsersDAO.removeDelegatedToUser(authorizedUser, baseUser))
+            .then(cassandraUsersDAO.removeAllAuthorizedUsers(baseUser));
     }
 
     @Override
     public Publisher<Void> addAuthorizedUser(Username baseUser, Username userWithAccess) {
-        return cassandraUsersDAO.addAuthorizedUsers(baseUser, userWithAccess);
+        return cassandraUsersDAO.addAuthorizedUsers(baseUser, userWithAccess)
+            .then(Mono.from(cassandraUsersDAO.containsReactive(userWithAccess))
+                .filter(FunctionalUtils.identityPredicate())
+                .flatMap(authorizedUser -> cassandraUsersDAO.addDelegatedToUsers(userWithAccess, baseUser))

Review Comment:
   "to **achieve** atomicity".
   
   And this is not atomicity (batch brings no such guaranty) but more eventual consistency (all actions are eventually applied, or none).
   
   But yes, we need a (logged) batch here.



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