Skip to content

Commit

Permalink
[BACKPORT] PostgresMessageFastViewProjection should remove entries wh…
Browse files Browse the repository at this point in the history
…en delete mailbox

backport of #2635 for postgres-app

Co-authored-by: Rene Cordier <rcordier@linagora.com>
  • Loading branch information
quantranhong1999 and Arsnael committed Feb 28, 2025
1 parent b895341 commit 654a839
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
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;
Expand Down Expand Up @@ -65,6 +67,10 @@ protected void configure() {
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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;
Expand All @@ -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();
}
Original file line number Diff line number Diff line change
@@ -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 {

}

0 comments on commit 654a839

Please sign in to comment.