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


##########
server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/UserRoutes.java:
##########
@@ -61,6 +67,44 @@
 import spark.Service;
 
 public class UserRoutes implements Routes {
+    interface UserCondition {
+        boolean satisfyCondition(UserResponse user);
+    }
+
+    static class HasNoMailboxesCondition implements UserCondition {
+        private final UserMailboxesService userMailboxesService;
+
+        public HasNoMailboxesCondition(UserMailboxesService 
userMailboxesService) {
+            this.userMailboxesService = userMailboxesService;
+        }
+
+        @Override
+        public boolean satisfyCondition(UserResponse user) {
+            try {
+                return 
userMailboxesService.listMailboxes(Username.of(user.getUsername())).isEmpty();
+            } catch (UsersRepositoryException e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+
+    static class HasNotAccessAllSystemMailboxesCondition implements 
UserCondition {
+        private final UserMailboxesService userMailboxesService;
+
+        public HasNotAccessAllSystemMailboxesCondition(UserMailboxesService 
userMailboxesService) {
+            this.userMailboxesService = userMailboxesService;
+        }
+
+        @Override
+        public boolean satisfyCondition(UserResponse user) {
+            try {
+                List<Mailbox> mailboxes = 
userMailboxesService.listMailboxes(Username.of(user.getUsername()));
+                return mailboxes.size() == 1 && 
DefaultMailboxes.INBOX.equals(mailboxes.getFirst().getName());

Review Comment:
   I checked the case "User never logged in but receives emails" by integration 
test and see that when user never login but still receive some emails, the 
"INBOX" mailbox is created automatically and this is the only mailbox created.
   
   Therefore, I think this code is correct.



-- 
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-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to