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
|
|
@ -48,7 +48,12 @@ function admin_users_list(): void
|
|||
FROM users u LEFT JOIN employees e ON e.id = u.employee_id
|
||||
ORDER BY u.last_name, u.first_name';
|
||||
$users = db()->query($sql)->fetchAll();
|
||||
render_page('admin_users', ['users' => $users], 'Benutzer');
|
||||
render_page('admin_users', [
|
||||
'users' => $users,
|
||||
'pushCounts' => push_counts_by_user(),
|
||||
'pushLastUpdate' => push_last_update_by_user(),
|
||||
'pushConfigured' => push_is_configured(),
|
||||
], 'Benutzer');
|
||||
}
|
||||
|
||||
function admin_user_form(?int $id): void
|
||||
|
|
@ -209,6 +214,8 @@ function admin_user_form(?int $id): void
|
|||
'values' => $values,
|
||||
'errors' => $errors,
|
||||
'employees' => $employees,
|
||||
'pushCount' => $editing ? push_subscription_count((int) $editing['id']) : 0,
|
||||
'pushAvailable' => push_is_configured(),
|
||||
], $editing ? 'Benutzer bearbeiten' : 'Benutzer anlegen');
|
||||
}
|
||||
|
||||
|
|
@ -377,13 +384,24 @@ function admin_trailers(): void
|
|||
function admin_reminders_send(): void
|
||||
{
|
||||
require_post();
|
||||
$result = reminder_send_due();
|
||||
if (!$result['enabled']) {
|
||||
flash('info', 'Der E-Mail-Versand ist in der Konfiguration deaktiviert. Die Erinnerungen bleiben in der App sichtbar.');
|
||||
} elseif ($result['errors']) {
|
||||
flash('error', implode(' ', $result['errors']));
|
||||
$push = push_dispatch_due();
|
||||
$mail = reminder_send_due();
|
||||
$parts = [];
|
||||
if (push_is_configured()) {
|
||||
$parts[] = sprintf(
|
||||
'Push: %d gesendet, %d fehlgeschlagen, %d abgelaufene Abos entfernt.',
|
||||
$push['sent'], $push['failed'], $push['removed']
|
||||
);
|
||||
} else {
|
||||
flash('success', 'E-Mail-Versand ausgeführt: ' . $result['sent'] . ' Erinnerung(en) versendet, ' . $result['skipped'] . ' übersprungen.');
|
||||
$parts[] = 'Push ist nicht konfiguriert.';
|
||||
}
|
||||
if (!$mail['enabled']) {
|
||||
$parts[] = 'E-Mail-Versand ist deaktiviert.';
|
||||
} elseif ($mail['errors']) {
|
||||
$parts[] = 'E-Mail-Fehler: ' . implode(' ', $mail['errors']);
|
||||
} else {
|
||||
$parts[] = sprintf('E-Mail: %d versendet, %d übersprungen.', $mail['sent'], $mail['skipped']);
|
||||
}
|
||||
flash($mail['errors'] ? 'error' : 'success', implode(' ', $parts));
|
||||
redirect('/reminders');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue