Web-Push mit VAPID und Erinnerungs-Endpoint
This commit is contained in:
parent
67a1614081
commit
b50267e4f0
24 changed files with 1703 additions and 50 deletions
|
|
@ -2,14 +2,13 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Täglicher Erinnerungs-Digest per E-Mail.
|
||||
* Täglicher Erinnerungslauf (Push + optional E-Mail).
|
||||
*
|
||||
* Cron-Beispiel (täglich 07:00):
|
||||
* 0 7 * * * /usr/bin/php /pfad/zu/drink-it-cold/tools/send_reminders.php
|
||||
*
|
||||
* Voraussetzung: app.mail_enabled = true und Benutzer mit E-Mail-Adresse,
|
||||
* die mit einem Mitarbeiterkonto verknüpft sind. Die In-App-Erinnerungen
|
||||
* funktionieren unabhängig davon.
|
||||
* Alternativ von außen über den token-geschützten Endpoint:
|
||||
* https://…/cron/reminders?token=<cron_token>
|
||||
*/
|
||||
|
||||
require __DIR__ . '/../app/bootstrap.php';
|
||||
|
|
@ -21,22 +20,28 @@ foreach ($argv ?? [] as $arg) {
|
|||
}
|
||||
}
|
||||
|
||||
$result = reminder_send_due($lookback);
|
||||
$push = push_dispatch_due($lookback);
|
||||
$mail = reminder_send_due($lookback);
|
||||
|
||||
if (!$result['enabled']) {
|
||||
fwrite(STDOUT, "E-Mail-Versand ist deaktiviert (app.mail_enabled = false).\n");
|
||||
exit(0);
|
||||
if (!push_is_configured()) {
|
||||
fwrite(STDOUT, "Push: nicht konfiguriert (VAPID-Schlüssel fehlen).\n");
|
||||
} else {
|
||||
fwrite(STDOUT, sprintf(
|
||||
"Push: %d gesendet, %d fehlgeschlagen, %d abgelaufene Abos entfernt, %d ohne Abo.\n",
|
||||
$push['sent'], $push['failed'], $push['removed'], $push['skipped_no_subscription']
|
||||
));
|
||||
}
|
||||
|
||||
fwrite(STDOUT, sprintf(
|
||||
"Erinnerungen: %d versendet, %d übersprungen.\n",
|
||||
$result['sent'],
|
||||
$result['skipped']
|
||||
));
|
||||
foreach ($result['details'] as $detail) {
|
||||
fwrite(STDOUT, ' ' . $detail . "\n");
|
||||
if (!$mail['enabled']) {
|
||||
fwrite(STDOUT, "E-Mail: deaktiviert.\n");
|
||||
} else {
|
||||
fwrite(STDOUT, sprintf("E-Mail: %d versendet, %d übersprungen.\n", $mail['sent'], $mail['skipped']));
|
||||
foreach ($mail['details'] as $detail) {
|
||||
fwrite(STDOUT, ' ' . $detail . "\n");
|
||||
}
|
||||
foreach ($mail['errors'] as $error) {
|
||||
fwrite(STDERR, ' Fehler: ' . $error . "\n");
|
||||
}
|
||||
}
|
||||
foreach ($result['errors'] as $error) {
|
||||
fwrite(STDERR, ' Fehler: ' . $error . "\n");
|
||||
}
|
||||
exit($result['errors'] ? 1 : 0);
|
||||
|
||||
exit(($mail['errors'] || $push['failed'] > 0) ? 1 : 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue