KB68 Only put public posts into the newsletter.
Change-Id: Iee7f4dfd14820c19179c43be71759f209caa9989
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java
index 59ab37c..7a52d32 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java
@@ -50,7 +50,15 @@
void run() throws InterruptedException, TimeoutException, ExecutionException {
var session = em.unwrap(Session.class);
- List<Post<?>> posts = Post.list("newsletter IS NULL", Sort.ascending("date"));
+ List<Post<?>> posts =
+ Post.list(
+ ""
+ + "SELECT p FROM Post p"
+ + " JOIN p.targets r"
+ + " JOIN r.tags tag"
+ + " WHERE newsletter IS NULL"
+ + " AND tag = 'world'",
+ Sort.ascending("date"));
Post.fetchTexts(posts);
if (posts.isEmpty()) {
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java
index 43787dc..a9dda9c 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSubscriptionExpirer.java
@@ -16,8 +16,7 @@
void run() {
var subscriptionsDeleted =
NewsletterSubscription.delete(
- "registrationKey IS NOT NULL AND startDate < ?1",
- OffsetDateTime.now().minusWeeks(1));
+ "registrationKey IS NOT NULL AND startDate < ?1", OffsetDateTime.now().minusWeeks(1));
if (subscriptionsDeleted > 0) {
log.infof("%d expired newsletter subscriptions deleted.", subscriptionsDeleted);
}