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 8bcd630d90 JAMES-4090 Disconnector for Push Subscription (#2520)
8bcd630d90 is described below

commit 8bcd630d90c833a02f8b17cdd876e3124f2fab0b
Author: Benoit TELLIER <btell...@linagora.com>
AuthorDate: Tue Nov 26 09:55:53 2024 +0100

    JAMES-4090 Disconnector for Push Subscription (#2520)
    
    This will effectively kill mobile notifications for that user.
---
 .../james/jmap/rfc8621/RFC8621MethodsModule.java   |  2 +
 .../PushSubscriptionDisconnector.java              | 50 ++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git 
a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/rfc8621/RFC8621MethodsModule.java
 
b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/rfc8621/RFC8621MethodsModule.java
index 05e789d9df..55a26bd215 100644
--- 
a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/rfc8621/RFC8621MethodsModule.java
+++ 
b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/rfc8621/RFC8621MethodsModule.java
@@ -32,6 +32,7 @@ import org.apache.james.jmap.JMAPRoutes;
 import org.apache.james.jmap.JMAPRoutesHandler;
 import org.apache.james.jmap.Version;
 import org.apache.james.jmap.api.model.TypeName;
+import org.apache.james.jmap.api.pushsubscription.PushSubscriptionDisconnector;
 import org.apache.james.jmap.api.upload.UploadService;
 import org.apache.james.jmap.api.upload.UploadServiceDefaultImpl;
 import org.apache.james.jmap.change.EmailDeliveryTypeName$;
@@ -204,6 +205,7 @@ public class RFC8621MethodsModule extends AbstractModule {
         Multibinder<Disconnector> disconnectorMultibinder = 
Multibinder.newSetBinder(binder(), Disconnector.class);
         disconnectorMultibinder.addBinding().to(WebSocketRoutes.class);
         disconnectorMultibinder.addBinding().to(EventSourceRoutes.class);
+        
disconnectorMultibinder.addBinding().to(PushSubscriptionDisconnector.class);
     }
 
     @ProvidesIntoSet
diff --git 
a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/pushsubscription/PushSubscriptionDisconnector.java
 
b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/pushsubscription/PushSubscriptionDisconnector.java
new file mode 100644
index 0000000000..fecdd1df86
--- /dev/null
+++ 
b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/pushsubscription/PushSubscriptionDisconnector.java
@@ -0,0 +1,50 @@
+/******************************************************************
+ * 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.api.pushsubscription;
+
+import java.util.function.Predicate;
+
+import jakarta.inject.Inject;
+
+import org.apache.james.core.Disconnector;
+import org.apache.james.core.Username;
+import org.apache.james.user.api.UsersRepository;
+
+import reactor.core.publisher.Flux;
+
+public class PushSubscriptionDisconnector implements Disconnector {
+    private final UsersRepository usersRepository;
+    private final PushSubscriptionRepository repository;
+
+    @Inject
+    public PushSubscriptionDisconnector(UsersRepository usersRepository, 
PushSubscriptionRepository repository) {
+        this.usersRepository = usersRepository;
+        this.repository = repository;
+    }
+
+    @Override
+    public void disconnect(Predicate<Username> username) {
+        Flux.from(usersRepository.listReactive())
+            .filter(username)
+            .flatMap(repository::delete)
+            .then()
+            .block();
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to