diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2020-11-03 06:49:57 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2020-11-03 06:50:27 +0100 |
commit | db9a1988bc688407c7957c5e55782f33a76d3de3 (patch) | |
tree | 6b4078d5634cee3198a62b1226b3c4ae9e180008 | |
parent | ff358945f2b210f7f374d3e3e7e36170ee16aed5 (diff) |
KB68 Automatic expiry of unconfirmed newsletter subscriptions.
Change-Id: Iae05f0cac1bacc7e1929a0b3a72d506241c2ece3
-rw-r--r-- | src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java | 25 |
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); + } + } +} |