Todo: scheduled Discord notifications via cron
Deploy HouseHub / deploy (push) Successful in 2s

- cron/todo_notify.php: checks every minute for tasks due now and sends
  Discord reminder () only when due_date+due_time is reached
- No immediate notification when due_time is set (cron handles it)
- Immediate notification still fires for tasks without a due_time
- notified column tracks whether reminder was already sent
- Resets notified=0 when a task is edited (new time picked)
- Cron runs via: docker exec househub php /var/www/html/cron/todo_notify.php

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
perco
2026-05-12 14:55:27 +02:00
co-authored by Claude Sonnet 4.6
parent 6ef3b26153
commit d913f3c0eb
3 changed files with 105 additions and 2 deletions
+6 -2
View File
@@ -122,7 +122,10 @@ if ($action === 'todos') {
$new = $pdo->prepare("SELECT t.*, l.name as list_name, l.color as list_color, l.icon as list_icon FROM pf_todos t LEFT JOIN pf_todo_lists l ON l.id = t.list_id WHERE t.id=?");
$new->execute([$id]);
$row = $new->fetch();
discordNotify($pdo, "📋 **Nouvelle tâche** : " . $title . ($row['list_name'] ? " _(". $row['list_name'] .")_" : ""));
// Only notify immediately if no due_time (otherwise cron sends it at the right time)
if (empty($d['due_time'])) {
discordNotify($pdo, "📋 **Nouvelle tâche** : " . $title . ($row['list_name'] ? " _(". $row['list_name'] .")_" : ""));
}
tOk($row);
}
@@ -145,7 +148,8 @@ if ($action === 'todos') {
// Full update
$title = trim($d['title'] ?? ''); if (!$title) tErr('Titre requis');
$pdo->prepare("UPDATE pf_todos SET list_id=?, title=?, notes=?, due_date=?, due_time=?, priority=?, updated_at=NOW() WHERE id=?")
// Reset notified if due_time changed
$pdo->prepare("UPDATE pf_todos SET list_id=?, title=?, notes=?, due_date=?, due_time=?, priority=?, notified=0, updated_at=NOW() WHERE id=?")
->execute([$d['list_id'] ?: null, $title, $d['notes'] ?? null, $d['due_date'] ?: null, $d['due_time'] ?: null, $d['priority'] ?? 'none', $id]);
tOk(['updated' => true]);
}