This is an automated email from the ASF dual-hosted git repository.
hqtran 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 654a839e51 [BACKPORT] PostgresMessageFastViewProjection should remove
entries when delete mailbox
654a839e51 is described below
commit 654a839e51dde9e0c3271f8f30f657f2c6079181
Author: Quan Tran <[email protected]>
AuthorDate: Thu Feb 27 17:17:08 2025 +0700
[BACKPORT] PostgresMessageFastViewProjection should remove entries when
delete mailbox
backport of https://github.com/apache/james-project/pull/2635 for
postgres-app
Co-authored-by: Rene Cordier <[email protected]>
---
.../james/modules/data/PostgresDataJmapModule.java | 6 +++
...sMessageFastViewProjectionDeletionCallback.java | 44 ++++++++++++++++++++++
.../james/jmap/rfc8621/postgres/PostgresBase.java | 4 +-
.../rfc8621/postgres/PostgresJmapPreviewTest.java | 26 +++++++++++++
4 files changed, 79 insertions(+), 1 deletion(-)
diff --git
a/server/container/guice/postgres-common/src/main/java/org/apache/james/modules/data/PostgresDataJmapModule.java
b/server/container/guice/postgres-common/src/main/java/org/apache/james/modules/data/PostgresDataJmapModule.java
index b9a34ab194..19ecf9a84e 100644
---
a/server/container/guice/postgres-common/src/main/java/org/apache/james/modules/data/PostgresDataJmapModule.java
+++
b/server/container/guice/postgres-common/src/main/java/org/apache/james/modules/data/PostgresDataJmapModule.java
@@ -37,7 +37,9 @@ import
org.apache.james.jmap.postgres.identity.PostgresCustomIdentityDAO;
import org.apache.james.jmap.postgres.projections.PostgresEmailQueryView;
import
org.apache.james.jmap.postgres.projections.PostgresEmailQueryViewManager;
import
org.apache.james.jmap.postgres.projections.PostgresMessageFastViewProjection;
+import
org.apache.james.jmap.postgres.projections.PostgresMessageFastViewProjectionDeletionCallback;
import org.apache.james.jmap.postgres.upload.PostgresUploadRepository;
+import org.apache.james.mailbox.postgres.DeleteMessageListener;
import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
import org.apache.james.user.api.DeleteUserDataTaskStep;
import org.apache.james.user.api.UsernameChangeTaskStep;
@@ -65,6 +67,10 @@ public class PostgresDataJmapModule extends AbstractModule {
bind(PostgresMessageFastViewProjection.class).in(Scopes.SINGLETON);
bind(MessageFastViewProjection.class).to(PostgresMessageFastViewProjection.class);
+ Multibinder.newSetBinder(binder(),
DeleteMessageListener.DeletionCallback.class)
+ .addBinding()
+ .to(PostgresMessageFastViewProjectionDeletionCallback.class);
+
bind(PostgresEmailQueryView.class).in(Scopes.SINGLETON);
bind(EmailQueryView.class).to(PostgresEmailQueryView.class);
bind(PostgresEmailQueryView.class).in(Scopes.SINGLETON);
diff --git
a/server/data/data-jmap-postgres/src/main/java/org/apache/james/jmap/postgres/projections/PostgresMessageFastViewProjectionDeletionCallback.java
b/server/data/data-jmap-postgres/src/main/java/org/apache/james/jmap/postgres/projections/PostgresMessageFastViewProjectionDeletionCallback.java
new file mode 100644
index 0000000000..3cbacec71a
--- /dev/null
+++
b/server/data/data-jmap-postgres/src/main/java/org/apache/james/jmap/postgres/projections/PostgresMessageFastViewProjectionDeletionCallback.java
@@ -0,0 +1,44 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.jmap.postgres.projections;
+
+import jakarta.inject.Inject;
+
+import org.apache.james.core.Username;
+import org.apache.james.jmap.api.projections.MessageFastViewProjection;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.postgres.DeleteMessageListener;
+import org.apache.james.mailbox.postgres.mail.MessageRepresentation;
+
+import reactor.core.publisher.Mono;
+
+public class PostgresMessageFastViewProjectionDeletionCallback implements
DeleteMessageListener.DeletionCallback {
+ private final MessageFastViewProjection messageFastViewProjection;
+
+ @Inject
+ public
PostgresMessageFastViewProjectionDeletionCallback(MessageFastViewProjection
messageFastViewProjection) {
+ this.messageFastViewProjection = messageFastViewProjection;
+ }
+
+ @Override
+ public Mono<Void> forMessage(MessageRepresentation messageRepresentation,
MailboxId mailboxId, Username owner) {
+ return
Mono.from(messageFastViewProjection.delete(messageRepresentation.getMessageId()));
+ }
+}
diff --git
a/server/protocols/jmap-rfc-8621-integration-tests/postgres-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/postgres/PostgresBase.java
b/server/protocols/jmap-rfc-8621-integration-tests/postgres-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/postgres/PostgresBase.java
index 3c33d39221..7ce237edb4 100644
---
a/server/protocols/jmap-rfc-8621-integration-tests/postgres-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/postgres/PostgresBase.java
+++
b/server/protocols/jmap-rfc-8621-integration-tests/postgres-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/postgres/PostgresBase.java
@@ -28,6 +28,7 @@ import org.apache.james.PostgresJamesServerMain;
import org.apache.james.SearchConfiguration;
import org.apache.james.backends.postgres.PostgresExtension;
import org.apache.james.jmap.rfc8621.contract.IdentityProbeModule;
+import org.apache.james.jmap.rfc8621.contract.JmapPreviewProbeModule;
import org.apache.james.jmap.rfc8621.contract.probe.DelegationProbeModule;
import org.apache.james.modules.RabbitMQExtension;
import org.apache.james.modules.TestJMAPServerModule;
@@ -54,6 +55,7 @@ public class PostgresBase {
.server(configuration ->
PostgresJamesServerMain.createServer(configuration)
.overrideWith(new TestJMAPServerModule())
.overrideWith(new DelegationProbeModule())
- .overrideWith(new IdentityProbeModule()))
+ .overrideWith(new IdentityProbeModule())
+ .overrideWith(new JmapPreviewProbeModule()))
.build();
}
diff --git
a/server/protocols/jmap-rfc-8621-integration-tests/postgres-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/postgres/PostgresJmapPreviewTest.java
b/server/protocols/jmap-rfc-8621-integration-tests/postgres-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/postgres/PostgresJmapPreviewTest.java
new file mode 100644
index 0000000000..9e954d91f7
--- /dev/null
+++
b/server/protocols/jmap-rfc-8621-integration-tests/postgres-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/postgres/PostgresJmapPreviewTest.java
@@ -0,0 +1,26 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.jmap.rfc8621.postgres;
+
+import org.apache.james.jmap.rfc8621.contract.JmapPreviewContract;
+
+public class PostgresJmapPreviewTest extends PostgresBase implements
JmapPreviewContract {
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]