summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java
new file mode 100644
index 0000000..43787dc
--- /dev/null
+++ b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java
@@ -0,0 +1,25 @@
+package eu.mulk.mulkcms2.benki.newsletter;
+
+import io.quarkus.scheduler.Scheduled;
+import java.time.OffsetDateTime;
+import javax.enterprise.context.Dependent;
+import javax.transaction.Transactional;
+import org.jboss.logging.Logger;
+
+@Dependent
+public class NewsletterSubscriptionExpirer {
+
+ private static final Logger log = Logger.getLogger(NewsletterUnsubscriber.class);
+
+ @Scheduled(every = "PT1H")
+ @Transactional
+ void run() {
+ var subscriptionsDeleted =
+ NewsletterSubscription.delete(
+ "registrationKey IS NOT NULL AND startDate < ?1",
+ OffsetDateTime.now().minusWeeks(1));
+ if (subscriptionsDeleted > 0) {
+ log.infof("%d expired newsletter subscriptions deleted.", subscriptionsDeleted);
+ }
+ }
+}