You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2023/06/14 06:59:47 UTC
[james-project] 25/28: JAMES-3914 Sieve Reject: support several recipients
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit d5bad56ca55ec067e392f05f36e7b19fab6125de
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Jun 12 16:26:04 2023 +0700
JAMES-3914 Sieve Reject: support several recipients
---
.../james/transport/mailets/jsieve/RejectAction.java | 5 ++---
.../mailets/delivery/SieveIntegrationTest.java | 19 +++++++++++++++++++
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java
index 9d0bdb7e59..32e3680404 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java
@@ -109,8 +109,7 @@ public class RejectAction implements MailAction {
originalRecipient = originalRecipients[0];
}
- MailAddress soleRecipient = ActionUtils.getSoleRecipient(aMail);
- String finalRecipient = soleRecipient.asString();
+ String finalRecipient = context.getRecipient().asString();
String originalMessageId = aMail.getMessage().getMessageID();
Multipart multipart = MDN.builder()
@@ -133,7 +132,7 @@ public class RejectAction implements MailAction {
// Send the message
MimeMessage reply = (MimeMessage) aMail.getMessage().reply(false);
- soleRecipient.toInternetAddress()
+ context.getRecipient().toInternetAddress()
.ifPresent(Throwing.<Address>consumer(reply::setFrom).sneakyThrow());
reply.setContent(multipart);
reply.saveChanges();
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java
index 47ede08af8..884dbfe606 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java
@@ -479,6 +479,25 @@ class SieveIntegrationTest {
assertThat(mail.getRecipients()).isEmpty();
}
+ @Test
+ void rejectShouldWorkWhenMultipleRecipients() throws Exception {
+ prepareTestUsingScript("org/apache/james/transport/mailets/delivery/reject.script");
+ when(usersRepository.getUsername(new MailAddress("other@domain.tld"))).thenReturn(Username.of("other@domain.tld"));
+ when(resourceLocator.get(new MailAddress("other@domain.tld"))).thenThrow(new ScriptNotFoundException());
+
+ FakeMail mail = createMail();
+ mail.setRecipients(ImmutableList.of(new MailAddress(RECEIVER_DOMAIN_COM), new MailAddress("other@domain.tld")));
+ testee.service(mail);
+
+ FakeMailContext.SentMail expectedSentMail = FakeMailContext.sentMailBuilder()
+ .recipient("sender@any.com")
+ .fromMailet()
+ .build();
+ assertThat(fakeMailContext.getSentMails())
+ .containsExactly(expectedSentMail);
+ assertThat(mail.getRecipients()).containsOnly(new MailAddress("other@domain.tld"));
+ }
+
@Test
void redirectShouldWorkWhenSeveralRecipients() throws Exception {
prepareTestUsingScript("org/apache/james/transport/mailets/delivery/redirect.script");
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org