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


##########
mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresMailboxMapper.java:
##########
@@ -96,21 +95,21 @@ public Flux<Mailbox> findNonPersonalMailboxes(Username 
userName, MailboxACL.Righ
 
     @Override
     public Mono<ACLDiff> updateACL(Mailbox mailbox, MailboxACL.ACLCommand 
mailboxACLCommand) {
-        return upsertACL(mailbox,
-            mailbox.getACL(),
-            Throwing.supplier(() -> 
mailbox.getACL().apply(mailboxACLCommand)).get());
+        return postgresMailboxDAO.getACL(mailbox.getMailboxId())
+            .flatMap(pairMailboxACLAndVersion -> {
+                try {
+                    MailboxACL newACL = 
pairMailboxACLAndVersion.getLeft().apply(mailboxACLCommand);
+                    return 
postgresMailboxDAO.upsertACL(mailbox.getMailboxId(), newACL, 
pairMailboxACLAndVersion.getRight())
+                        
.thenReturn(ACLDiff.computeDiff(pairMailboxACLAndVersion.getLeft(), newACL));

Review Comment:
   The generate `ACLDiff` base on result of query `upsertACL` will more reliable
   
   My mean:
   ```
   upsertACL(xxx)
   .map(newAclResult -> calculateACLDiff(newAclResult)))
   ```
   



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

Reply via email to