feat: integrate WAHA WhatsApp notifications for tasks, notes, and passwords with admin configuration settings
This commit is contained in:
@@ -4,16 +4,20 @@ $parent_id = $_GET['folder'] ?? null;
|
||||
if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['create_folder'])) {
|
||||
$stmt = $pdo->prepare("INSERT INTO projects (name, is_folder, parent_id, owner_id) VALUES (?, 1, ?, ?)");
|
||||
$stmt->execute([$_POST['name'], $parent_id, $user_id]);
|
||||
notify_waha('Created', 'Folder', $_POST['name']);
|
||||
}
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_item'])) {
|
||||
$item = query("SELECT name FROM projects WHERE id=?", [$_POST['item_id']])->fetch();
|
||||
$stmt = $pdo->prepare("DELETE FROM projects WHERE id=? AND owner_id=?");
|
||||
$stmt->execute([$_POST['item_id'], $user_id]);
|
||||
if($item) notify_waha('Deleted', 'File/Folder', $item['name']);
|
||||
}
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_item'])) {
|
||||
$stmt = $pdo->prepare("UPDATE projects SET name=? WHERE id=? AND owner_id=?");
|
||||
$stmt->execute([$_POST['new_name'], $_POST['item_id'], $user_id]);
|
||||
notify_waha('Renamed', 'File/Folder', $_POST['new_name']);
|
||||
}
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['upload_file']) && isset($_FILES['file'])) {
|
||||
@@ -24,6 +28,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['upload_file']) && isse
|
||||
move_uploaded_file($tmp_name, $path);
|
||||
$stmt = $pdo->prepare("INSERT INTO projects (name, is_folder, parent_id, file_path, owner_id) VALUES (?, 0, ?, ?, ?)");
|
||||
$stmt->execute([$name, $parent_id, $path, $user_id]);
|
||||
notify_waha('Uploaded', 'File', $name);
|
||||
echo "OK"; exit;
|
||||
}
|
||||
|
||||
@@ -38,6 +43,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['share_project'])) {
|
||||
$msg = "A project/file '{$pr['name']}' has been shared with you.";
|
||||
if($parts[0] === 'user') notify_user($parts[1], $msg);
|
||||
else notify_group($parts[1], $msg);
|
||||
notify_waha('Shared', 'File/Folder', $pr['name']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user