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


##########
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 purpose of postgresMailboxDAO.upsertACL is to replace the old acl in db 
with the new acl. Therefore, unless the operation fail, newACL is always the 
same as acl in db.



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