(james-project) branch master updated: [ENHANCEMENT] MDN/send shall be reactive

2024-05-16 Thread rcordier
This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 7acaac94f2 [ENHANCEMENT] MDN/send shall be reactive
7acaac94f2 is described below

commit 7acaac94f2cae728abffb5cd5dde393679c04f3c
Author: Benoit TELLIER 
AuthorDate: Thu May 16 12:00:28 2024 +0200

[ENHANCEMENT] MDN/send shall be reactive
---
 .../rfc8621/contract/MDNSendMethodContract.scala   | 12 +++--
 .../apache/james/jmap/method/MDNSendMethod.scala   | 59 --
 2 files changed, 39 insertions(+), 32 deletions(-)

diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MDNSendMethodContract.scala
 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MDNSendMethodContract.scala
index e029aa9299..ce4ac317cb 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MDNSendMethodContract.scala
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MDNSendMethodContract.scala
@@ -860,6 +860,7 @@ trait MDNSendMethodContract {
 .build(buildOriginalMessage("2")))
   .getMessageId
 
+val serializedRandomId = randomMessageId.serialize()
 val request: String =
   s"""{
  |  "using": [
@@ -891,7 +892,7 @@ trait MDNSendMethodContract {
  |}
  |  },
  |  "k1548": {
- |"forEmailId": "${randomMessageId.serialize()}",
+ |"forEmailId": "$serializedRandomId",
  |"disposition": {
  |  "actionMode": "manual-action",
  |  "sendingMode": "mdn-sent-manually",
@@ -957,7 +958,7 @@ trait MDNSendMethodContract {
|},
|"k1548": {
|"type": "notFound",
-   |"description": "The reference 
\\"forEmailId\\" cannot be found."
+   |"description": "The reference 
\\"forEmailId\\" $serializedRandomId cannot be found for user an...@domain.tld."
|}
|}
|},
@@ -1177,6 +1178,7 @@ trait MDNSendMethodContract {
 val mailboxProbe: MailboxProbeImpl = 
server.getProbe(classOf[MailboxProbeImpl])
 mailboxProbe.createMailbox(path)
 
+val randomMessageId1 = randomMessageId
 val request: String =
   s"""{
  |  "using": [
@@ -1192,7 +1194,7 @@ trait MDNSendMethodContract {
  |"identityId": "$IDENTITY_ID",
  |"send": {
  |  "k1546": {
- |"forEmailId": "${randomMessageId.serialize()}",
+ |"forEmailId": "${randomMessageId1.serialize()}",
  |"disposition": {
  |  "actionMode": "manual-action",
  |  "sendingMode": "mdn-sent-manually",
@@ -1225,10 +1227,10 @@ trait MDNSendMethodContract {
 
 assertThatJson(response)
   .inPath("methodResponses[0][1].notSent")
-  .isEqualTo("""{
+  .isEqualTo(s"""{
|"k1546": {
|"type": "notFound",
-   |"description": "The reference \"forEmailId\" 
cannot be found."
+   |"description": "The reference \\\"forEmailId\\\" 
${randomMessageId1.serialize()} cannot be found for user b...@domain.tld."
|}
|}""".stripMargin)
   }
diff --git 
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MDNSendMethod.scala
 
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MDNSendMethod.scala
index acfa6240b5..a6a541cb99 100644
--- 
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MDNSendMethod.scala
+++ 
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MDNSendMethod.scala
@@ -19,6 +19,7 @@
 
 package org.apache.james.jmap.method
 
+import com.google.common.collect.ImmutableList
 import eu.timepit.refined.auto._
 import jakarta.annotation.PreDestroy
 import jakarta.inject.Inject
@@ -47,7 +48,6 @@ import org.apache.james.mime4j.stream.MimeConfig
 import org.apache.james.queue.api.MailQueueFactory.SPOOL
 import org.apache.james.queue.api.{MailQueue, MailQueueFactory}
 import org.apache.james.server.core.MailImpl
-import org.apache.james.util.ReactorUtils
 import 

Re: [PR] [ENHANCEMENT] MDN/send shall be reactive [james-project]

2024-05-16 Thread via GitHub


Arsnael merged PR #2247:
URL: https://github.com/apache/james-project/pull/2247


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



[PR] [ENHANCEMENT] Allow custom prefetch in Flux => InputStream convertions [james-project]

2024-05-16 Thread via GitHub


chibenwa opened a new pull request, #2248:
URL: https://github.com/apache/james-project/pull/2248

   `boundedElastic` threads as well as AWS response threads spends a lot of 
time blocking on this, adding a prefertch could smooth things up and help 
having a lower thread count as well as lower user facing latencies.
   
   
![image](https://github.com/apache/james-project/assets/6928740/e3222aaf-84ee-4e11-af0c-5785bfd4bcca)
   
   Up to 25% wall clock time.


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



(james-project) branch master updated: [ENHANCEMENT] Apply RabbitMQ classic queue version 2 (#2243)

2024-05-16 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new e8aec7e00c [ENHANCEMENT] Apply RabbitMQ classic queue version 2 (#2243)
e8aec7e00c is described below

commit e8aec7e00c20605d46bb3bbe93087869d53b8b5d
Author: Trần Hồng Quân <55171818+quantranhong1...@users.noreply.github.com>
AuthorDate: Thu May 16 18:41:54 2024 +0700

[ENHANCEMENT] Apply RabbitMQ classic queue version 2 (#2243)

* [ENHANCEMENT] Apply classic queue version 2

Claimed to be better than version 1 cf:
- 
https://www.rabbitmq.com/blog/2023/05/17/rabbitmq-3.12-performance-improvements#classic-queues-massively-improved-classic-queues-v2-cqv2
- 
https://www.rabbitmq.com/blog/2023/05/17/rabbitmq-3.12-performance-improvements#312-cqv1-vs-cqv2
---
 .../org/apache/james/backends/rabbitmq/QueueArguments.java   |  5 +
 .../james/backends/rabbitmq/RabbitMQConfiguration.java   |  9 +
 upgrade-instructions.md  | 12 
 3 files changed, 26 insertions(+)

diff --git 
a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/QueueArguments.java
 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/QueueArguments.java
index 3a441b7446..576ef41aba 100644
--- 
a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/QueueArguments.java
+++ 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/QueueArguments.java
@@ -70,6 +70,11 @@ public class QueueArguments {
 return this;
 }
 
+public Builder classicQueueVersion(int version) {
+arguments.put("x-queue-version", version);
+return this;
+}
+
 public Builder put(String key, Object value) {
 arguments.put(key, value);
 return this;
diff --git 
a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQConfiguration.java
 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQConfiguration.java
index 150b7fd838..7c5071a44d 100644
--- 
a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQConfiguration.java
+++ 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQConfiguration.java
@@ -601,6 +601,7 @@ public class RabbitMQConfiguration {
 
 private static final String URI_PROPERTY_NAME = "uri";
 private static final String MANAGEMENT_URI_PROPERTY_NAME = 
"management.uri";
+private static final boolean FALLBACK_CLASSIC_QUEUES_VERSION_1 = 
Boolean.parseBoolean(System.getProperty("fallback.classic.queues.v1", "false"));
 
 public static RequireAmqpUri builder() {
 return amqpUri -> managementUri -> managementCredentials -> new 
Builder(amqpUri, managementUri, managementCredentials);
@@ -817,10 +818,18 @@ public class RabbitMQConfiguration {
 if (useQuorumQueues) {
 
builder.quorumQueue().replicationFactor(quorumQueueReplicationFactor);
 quorumQueueDeliveryLimit.ifPresent(builder::deliveryLimit);
+} else {
+applyClassicQueueArguments(builder);
 }
 return builder;
 }
 
+private void applyClassicQueueArguments(QueueArguments.Builder builder) {
+if (!FALLBACK_CLASSIC_QUEUES_VERSION_1) {
+builder.classicQueueVersion(2);
+}
+}
+
 public boolean isQuorumQueuesUsed() {
 return useQuorumQueues;
 }
diff --git a/upgrade-instructions.md b/upgrade-instructions.md
index 59feaa8c3c..bbfb543f4b 100644
--- a/upgrade-instructions.md
+++ b/upgrade-instructions.md
@@ -30,6 +30,18 @@ Change list:
  - [Java 21](#java-21)
  - [javax -> jakarta](#javax---jakarta)
  - [Make all queues on RabbitMQ quorum queue when 
`quorum.queues.enable=true`](#make-all-queues-on-rabbitmq-quorum-queue-when-quorumqueuesenabletrue)
+ - [Migrate RabbitMQ classic queues to version 
2](#migrate-rabbitmq-classic-queues-to-version-2)
+
+### Migrate RabbitMQ classic queues to version 2
+
+Date: 14/05/2024
+
+It is recommended by RabbitMQ to upgrade the classic queues to version 2 for 
better performance: 
https://www.rabbitmq.com/blog/2023/05/17/rabbitmq-3.12-performance-improvements#classic-queues-massively-improved-classic-queues-v2-cqv2.
+
+Existing version 1 classic queues would need to be deleted and let James 
re-create them as version 2.
+
+Notice that to use classic queues version 2, you need at least RabbitMQ 
3.10.0. If you want to stick with the older RabbitMQ 
+versions and avoid this breaking change, you could set the JVM property 
`fallback.classic.queues.v1` to `true` (defaults to `false`).
 
 ### Change cluster.enabled in redis.properties to redis.topology
 



Re: [PR] [ENHANCEMENT] Apply RabbitMQ classic queue version 2 [james-project]

2024-05-16 Thread via GitHub


chibenwa merged PR #2243:
URL: https://github.com/apache/james-project/pull/2243


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



[PR] [ENHANCEMENT] MDN/send shall be reactive [james-project]

2024-05-16 Thread via GitHub


chibenwa opened a new pull request, #2247:
URL: https://github.com/apache/james-project/pull/2247

   (no comment)


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



Re: [PR] JAMES-3693 Enable automatic update of redis cluster change [james-project]

2024-05-16 Thread via GitHub


hungphan227 closed pull request #2229: JAMES-3693 Enable automatic update of 
redis cluster change
URL: https://github.com/apache/james-project/pull/2229


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



Re: [PR] JAMES-3693 Enable automatic update of redis cluster change [james-project]

2024-05-16 Thread via GitHub


hungphan227 commented on PR #2229:
URL: https://github.com/apache/james-project/pull/2229#issuecomment-2114676748

   I still think the lua script issue relates to this PR. Close for now. I will 
create another PR in https://github.com/linagora/james-project/issues/5181


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



Re: [PR] JAMES-3693 Enable automatic update of redis cluster change [james-project]

2024-05-16 Thread via GitHub


Arsnael commented on PR #2229:
URL: https://github.com/apache/james-project/pull/2229#issuecomment-2114454389

   @hungphan227 can you please rebase this work?


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



Re: [PR] 3JAMES-4034 SMTP submission: validate FROM header [james-project]

2024-05-16 Thread via GitHub


chibenwa commented on code in PR #2246:
URL: https://github.com/apache/james-project/pull/2246#discussion_r1602672602


##
server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationHook.java:
##
@@ -90,4 +98,55 @@ protected boolean isSenderAllowed(Username connectedUser, 
Username sender) {
 }
 return allowed;
 }
+
+@Override
+public HookResult onMessage(SMTPSession session, Mail mail) {
+System.out.println("mess");
+ExtendedSMTPSession nSession = (ExtendedSMTPSession) session;
+if (nSession.verifyIdentity()) {
+try {
+return StreamUtils.ofNullable(mail.getMessage().getFrom())
+.distinct()
+.flatMap(address -> doCheckMessage(session, address))
+.findFirst()
+.orElse(HookResult.DECLINED);
+} catch (MessagingException e) {
+throw new RuntimeException(e);
+}
+} else {
+return HookResult.DECLINED;
+}
+}
+
+private Stream doCheckMessage(SMTPSession session, Address 
from) {
+if (fromDoesNotMatchAuthUser(session, from)) {
+return Stream.of(INVALID_AUTH);
+} else {
+return Stream.empty();
+}
+}
+
+private boolean fromDoesNotMatchAuthUser(SMTPSession session, Address 
from) {
+if (from instanceof InternetAddress internetAddress) {
+try {
+MailAddress mailAddress = new 
MailAddress(internetAddress.getAddress());
+return session.getUsername() != null &&
+(!fromMatchSessionUser(mailAddress, session) || 
!belongsToLocalDomain(mailAddress));

Review Comment:
   No need to be supported as
   
   1. that's the same validation layer than JMAP
   2. the authenticated user is identified as the delegated user 
(impersonnation) 



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