chibenwa commented on code in PR #2405:
URL: https://github.com/apache/james-project/pull/2405#discussion_r1754965894
##########
server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SubAddressing.java:
##########
@@ -55,20 +63,36 @@ public void service(Mail mail) throws MessagingException {
.ifPresent(
Throwing.consumer(details -> {
- boolean hasRight = mailboxManager.hasRight(
- MailboxPath.forUser(
-
Username.fromMailAddress(recipient.stripDetails("+")),
- details
- ),
- MailboxACL.Right.Post,
- session
- );
+ boolean hasRight;
+
+ try {
+ Username recipientUsername =
Username.fromLocalPartWithoutDomain(recipient.getLocalPartWithoutDetails("+"));
+ MailboxSession session =
mailboxManager.createSystemSession(recipientUsername);
- String targetFolder = hasRight ? details : "inbox";
+ MailboxACL aclCommand = mailboxManager.getMailbox(
+ MailboxPath.forUser(recipientUsername,
details), session)
+ .getMetaData(IGNORE, session,
MessageManager.MailboxMetaData.FetchGroup.NO_COUNT)
+ .getACL();
+ hasRight =
aclCommand.getEntries().containsKey(MailboxACL.ANYBODY_KEY) &&
+
aclCommand.getEntries().get(MailboxACL.ANYBODY_KEY).equals(MailboxACL.Rfc4314Rights.of(Collections.singletonList(MailboxACL.Right.Post)));
+
+ } catch (MailboxNotFoundException e) {
+ hasRight = false;
+ }
+
+ String targetFolder;
+ if(hasRight) {
+ targetFolder = details;
+ } else {
+ // TODO find LOG
+ // LOG.info(maybesender + " tried to address " +
recipient + "'s subfolder `" + details + "` but did not have the right to")
+ targetFolder = MailboxConstants.INBOX;
Review Comment:
Nope else we just do not do something. IE we only put the storage directive
when we have rights?
--
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]