feat: integrate WAHA WhatsApp notifications for tasks, notes, and passwords with admin configuration settings

This commit is contained in:
root
2026-03-29 16:42:30 +07:00
parent 8dedb57692
commit dbe02e52fd
7 changed files with 105 additions and 6 deletions

View File

@@ -43,6 +43,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST') {
}
$stmt = $pdo->prepare("INSERT INTO notes (title, content, owner_id, color, image_path, label_name) VALUES (?, ?, ?, ?, ?, ?)");
$stmt->execute([$_POST['title'] ?? 'Untitled', $_POST['content'], $user_id, $_POST['color'] ?? null, $image_path, trim($_POST['label_name'] ?? '') ?: null]);
notify_waha('Created', 'Note', $_POST['title'] ?? 'Untitled');
}
if(isset($_POST['update_note'])) {
@@ -67,14 +68,16 @@ if($_SERVER['REQUEST_METHOD'] === 'POST') {
}
$stmt = $pdo->prepare("UPDATE notes SET title=?, content=?, color=?, image_path=?, label_name=?, updated_at=CURRENT_TIMESTAMP WHERE id=? AND owner_id=?");
$stmt->execute([$_POST['title'] ?? 'Untitled', $_POST['content'], $_POST['color'] ?? null, $image_path, trim($_POST['label_name'] ?? '') ?: null, $_POST['note_id'], $user_id]);
notify_waha('Updated', 'Note', $_POST['title'] ?? 'Untitled');
}
}
if(isset($_POST['delete_note'])) {
$n = query("SELECT owner_id, image_path FROM notes WHERE id=?", [$_POST['note_id']])->fetch();
$n = query("SELECT owner_id, image_path, title FROM notes WHERE id=?", [$_POST['note_id']])->fetch();
if($n && $n['owner_id'] == $user_id) {
if($n['image_path'] && file_exists($n['image_path'])) @unlink($n['image_path']);
query("DELETE FROM notes WHERE id=? AND owner_id=?", [$_POST['note_id'], $user_id]);
notify_waha('Deleted', 'Note', $n['title'] ?? 'Untitled');
}
}
@@ -89,6 +92,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST') {
$msg = "A note '{$n['title']}' has been shared with you.";
if($parts[0] === 'user') notify_user($parts[1], $msg);
else notify_group($parts[1], $msg);
notify_waha('Shared', 'Note', $n['title'] ?? 'Untitled');
}
}