Skip to content

Commit 87f148d

Browse files
authored
feat: allow notifications on due date
fix: email notification test always sending to admins email fix: don't expose disabled notifications to ical feed
1 parent 8cec108 commit 87f148d

27 files changed

+38
-8
lines changed

api/subscriptions/get_ical_feed.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function getPriceConverted($price, $currency, $database)
111111
$paymentMethods[$paymentMethod['id']] = $paymentMethod['name'];
112112
}
113113

114-
$sql = "SELECT * FROM subscriptions WHERE user_id = :userId ORDER BY next_payment ASC";
114+
$sql = "SELECT * FROM subscriptions WHERE user_id = :userId AND inactive = 0 ORDER BY next_payment ASC";
115115

116116
$stmt = $db->prepare($sql);
117117
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);

endpoints/cronjobs/sendnotifications.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ function getDaysText($days) {
217217
$i = 0;
218218
$currentDate = new DateTime('now');
219219
while ($rowSubscription = $resultSubscriptions->fetchArray(SQLITE3_ASSOC)) {
220-
if ($rowSubscription['notify_days_before'] !== 0) {
220+
if ($rowSubscription['notify_days_before'] !== -1) {
221221
$daysToCompare = $rowSubscription['notify_days_before'];
222222
} else {
223223
$daysToCompare = $days;

endpoints/notifications/testemailnotifications.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
}
6161
$mail->Port = $smtpPort;
6262

63-
$getUser = "SELECT * FROM user WHERE id = 1";
63+
$getUser = "SELECT * FROM user WHERE id = $userId";
6464
$user = $db->querySingle($getUser, true);
6565
$email = $user['email'];
6666
$name = $user['username'];

includes/i18n/de.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "E-Mail Benachrichtigung aktivieren",
158158
"notify_me" => "Benachrichtige mich",
159159
"day_before" => "Tag bevor",
160+
"on_due_date" => "Am Fälligkeitsdatum",
160161
"days_before" => "Tage bevor",
161162
"smtp_address" => "SMTP Adresse",
162163
"port" => "Port",

includes/i18n/el.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "Ενεργοποίηση ειδοποιήσεων με email",
158158
"notify_me" => "Ειδοποίησε με",
159159
"day_before" => "ημέρα πριν",
160+
"on_due_date" => "την ημερομηνία λήξης",
160161
"days_before" => "ημέρες πριν",
161162
"smtp_address" => "SMTP Address",
162163
"port" => "Θύρα",

includes/i18n/en.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "Enable email notifications",
158158
"notify_me" => "Notify me",
159159
"day_before" => "day before",
160+
"on_due_date" => "On due date",
160161
"days_before" => "days before",
161162
"smtp_address" => "SMTP Address",
162163
"port" => "Port",

includes/i18n/es.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "Habilitar notificaciones por correo electrónico",
158158
"notify_me" => "Notificarme",
159159
"day_before" => "día antes",
160+
"on_due_date" => "En la fecha de vencimiento",
160161
"days_before" => "días antes",
161162
"smtp_address" => "Dirección SMTP",
162163
"port" => "Puerto",

includes/i18n/fr.php

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
"enable_email_notifications" => "Activer les notifications par courriel",
159159
"notify_me" => "Me prevenir",
160160
"day_before" => "jour avant",
161+
"on_due_date" => "Le jour de l'échéance",
161162
"days_before" => "jours avant",
162163
"smtp_address" => "Adresse SMTP",
163164
"port" => "Port",

includes/i18n/it.php

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
"enable_email_notifications" => 'Abilita le notifiche via e-mail',
166166
"notify_me" => 'Avvisami',
167167
"day_before" => 'giorno prima',
168+
"on_due_date" => 'Alla data di scadenza',
168169
"days_before" => 'giorni prima',
169170
"smtp_address" => 'Indirizzo SMTP',
170171
"port" => 'Porta',

includes/i18n/jp.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "電子メール通知を有効にする",
158158
"notify_me" => "通知",
159159
"day_before" => "日前",
160+
"on_due_date" => "支払い日",
160161
"days_before" => "日前",
161162
"smtp_address" => "SMTPアドレス",
162163
"port" => "ポート番号",

includes/i18n/ko.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "이메일 알림 활성화",
158158
"notify_me" => "알림 받기",
159159
"day_before" => "일 전",
160+
"on_due_date" => "만기일",
160161
"days_before" => "일 전",
161162
"smtp_address" => "SMTP 주소",
162163
"port" => "포트",

includes/i18n/nl.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "E-mail notificaties inschakelen",
158158
"notify_me" => "Informeer mij",
159159
"day_before" => "dag voor",
160+
"on_due_date" => "Op vervaldatum",
160161
"days_before" => "dagen voor",
161162
"smtp_address" => "SMTP-adres",
162163
"port" => "Poort",

includes/i18n/pl.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "Włącz powiadomienia e-mail",
158158
"notify_me" => "Powiadom mnie",
159159
"day_before" => "dzień wcześniej",
160+
"on_due_date" => "W dniu wymagalności",
160161
"days_before" => "dni wcześniej",
161162
"smtp_address" => "Adres SMTP",
162163
"port" => "Port",

includes/i18n/pt.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "Activar notificações por email",
158158
"notify_me" => "Notificar-me",
159159
"day_before" => "dia antes",
160+
"on_due_date" => "Na data de vencimento",
160161
"days_before" => "dias antes",
161162
"smtp_address" => "Endereço SMTP",
162163
"port" => "Porto",

includes/i18n/pt_br.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "Ativar notificações por email",
158158
"notify_me" => "Me notificar",
159159
"day_before" => "dia antes",
160+
"on_due_date" => "Na data de vencimento",
160161
"days_before" => "dias antes",
161162
"smtp_address" => "Endereço SMTP",
162163
"port" => "Porta",

includes/i18n/ru.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "Включить уведомления по электронной почте",
158158
"notify_me" => "Уведомить меня за",
159159
"day_before" => "день до события",
160+
"on_due_date" => "в день события",
160161
"days_before" => "дня(дней) до события",
161162
"smtp_address" => "SMTP-адрес",
162163
"port" => "Порт",

includes/i18n/sl.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "Omogoči e-poštna obvestila",
158158
"notify_me" => "Obvesti me",
159159
"day_before" => "dan prej",
160+
"on_due_date" => "Na dan zapadlosti",
160161
"days_before" => "dni prej",
161162
"smtp_address" => "SMTP naslov",
162163
"port" => "vrata",

includes/i18n/sr.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "Омогући обавештења е-поштом",
158158
"notify_me" => "Обавести ме",
159159
"day_before" => "дан пре",
160+
"on_due_date" => "на дан доспећа",
160161
"days_before" => "дана пре",
161162
"smtp_address" => "SMTP адреса",
162163
"port" => "Порт",

includes/i18n/sr_lat.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "Omogući obaveštenja e-poštom",
158158
"notify_me" => "Obavesti me",
159159
"day_before" => "dan pre",
160+
"on_due_date" => "Na dan dospeća",
160161
"days_before" => "dana pre",
161162
"smtp_address" => "SMTP adresa",
162163
"port" => "Port",

includes/i18n/tr.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "E-posta bildirimlerini etkinleştir",
158158
"notify_me" => "Beni bilgilendir",
159159
"day_before" => "bir gün önce",
160+
"on_due_date" => "Vadesinde",
160161
"days_before" => "günler önce",
161162
"smtp_address" => "SMTP Adresi",
162163
"port" => "Port",

includes/i18n/vi.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "Bật thông báo qua email",
158158
"notify_me" => "Thông báo cho tôi",
159159
"day_before" => "ngày trước",
160+
"on_due_date" => "Vào ngày đáo hạn",
160161
"days_before" => "ngày trước",
161162
"smtp_address" => "Địa chỉ SMTP",
162163
"port" => "Cổng",

includes/i18n/zh_cn.php

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
"enable_email_notifications" => "启用电子邮件通知",
166166
"notify_me" => "通知提前时间",
167167
"day_before" => "", // 设置标题(`notify_me`)中已经表明是提前多少天,因此这里直接用单位即可
168+
"on_due_date" => "到期日",
168169
"days_before" => "",
169170
"smtp_address" => "SMTP 地址",
170171
"port" => "端口",

includes/i18n/zh_tw.php

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"enable_email_notifications" => "啟用電子信箱通知",
158158
"notify_me" => "通知提前時間",
159159
"day_before" => "",
160+
"on_due_date" => "到期日當天",
160161
"days_before" => "",
161162
"smtp_address" => "SMTP 信箱地址",
162163
"port" => "連接埠",

includes/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php
2-
$version = "v2.43.1";
2+
$version = "v2.44.0";
33
?>

index.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,8 @@
570570
<div class="split66 mobile-split-50">
571571
<label for="notify_days_before"><?= translate('notify_me', $i18n) ?></label>
572572
<select id="notify_days_before" name="notify_days_before" disabled>
573-
<option value="0"><?= translate('default_value_from_settings', $i18n) ?></option>
573+
<option value="-1"><?= translate('default_value_from_settings', $i18n) ?></option>
574+
<option value="0"><?= translate('on_due_date', $i18n) ?></option>
574575
<option value="1">1 <?= translate('day_before', $i18n) ?></option>
575576
<?php
576577
for ($i = 2; $i <= 90; $i++) {

migrations/000034.php

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
// This migration changes all the notify_days_before from 0 to -1 to to support the added "on the day" option
3+
4+
$db->exec('UPDATE subscriptions SET `notify_days_before` = -1 WHERE `notify_days_before` = 0');

settings.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,18 @@ class="thin mobile-grow" />
322322
<label for="days"><?= translate('notify_me', $i18n) ?>:</label>
323323
<div class="form-group-inline">
324324
<select name="days" id="days">
325+
<option value="0" <?= $notifications['days'] == 0 ? "selected" : "" ?>>
326+
<?= translate('on_due_date', $i18n) ?>
327+
</option>
328+
<option value="1" <?= $notifications['days'] == 1 ? "selected" : "" ?>>
329+
1 <?= translate('day_before', $i18n) ?>
330+
</option>
325331
<?php
326-
for ($i = 1; $i <= 7; $i++) {
327-
$dayText = $i > 1 ? translate('days_before', $i18n) : translate('day_before', $i18n);
332+
for ($i = 2; $i <= 7; $i++) {
328333
$selected = $i == $notifications['days'] ? "selected" : "";
329334
?>
330335
<option value="<?= $i ?>" <?= $selected ?>>
331-
<?= $i ?> <?= $dayText ?>
336+
<?= $i ?> <?= translate('day_before', $i18n) ?>
332337
</option>
333338
<?php
334339
}

0 commit comments

Comments
 (0)