feat: integrate WAHA WhatsApp notifications for tasks, notes, and passwords with admin configuration settings
This commit is contained in:
@@ -28,6 +28,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if(isset($_POST['create_password'])) {
|
||||
$stmt = $pdo->prepare("INSERT INTO passwords (title, username, password, url, notes, owner_id, folder_id, tags) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$_POST['title'], $_POST['username'], $_POST['password'], $_POST['url'], $_POST['notes'], $user_id, $_POST['folder_id'] ?: null, trim($_POST['tags'] ?? '')]);
|
||||
notify_waha('Created', 'Password Entry', $_POST['title']);
|
||||
}
|
||||
|
||||
if(isset($_POST['update_password'])) {
|
||||
@@ -35,13 +36,15 @@ if($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if($p && $p['owner_id'] == $user_id) {
|
||||
$stmt = $pdo->prepare("UPDATE passwords SET title=?, username=?, password=?, url=?, notes=?, folder_id=?, tags=? WHERE id=? AND owner_id=?");
|
||||
$stmt->execute([$_POST['title'], $_POST['username'], $_POST['password'], $_POST['url'], $_POST['notes'], $_POST['folder_id'] ?: null, trim($_POST['tags'] ?? ''), $_POST['password_id'], $user_id]);
|
||||
notify_waha('Updated', 'Password Entry', $_POST['title']);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['delete_password'])) {
|
||||
$p = query("SELECT owner_id FROM passwords WHERE id=?", [$_POST['password_id']])->fetch();
|
||||
$p = query("SELECT owner_id, title FROM passwords WHERE id=?", [$_POST['password_id']])->fetch();
|
||||
if($p && $p['owner_id'] == $user_id) {
|
||||
query("DELETE FROM passwords WHERE id=? AND owner_id=?", [$_POST['password_id'], $user_id]);
|
||||
notify_waha('Deleted', 'Password Entry', $p['title']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +60,11 @@ if($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = $_POST['bulk_action'];
|
||||
if($action === 'delete') {
|
||||
foreach($selected as $p_id) {
|
||||
$p = query("SELECT owner_id FROM passwords WHERE id=?", [$p_id])->fetch();
|
||||
if($p && $p['owner_id']==$user_id) query("DELETE FROM passwords WHERE id=?", [$p_id]);
|
||||
$p = query("SELECT owner_id, title FROM passwords WHERE id=?", [$p_id])->fetch();
|
||||
if($p && $p['owner_id']==$user_id) {
|
||||
query("DELETE FROM passwords WHERE id=?", [$p_id]);
|
||||
notify_waha('Deleted', 'Password Entry', $p['title']);
|
||||
}
|
||||
}
|
||||
} elseif($action === 'share') {
|
||||
$share_target = $_POST['share_target'];
|
||||
@@ -72,6 +78,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$msg = "A password '{$p['title']}' has been shared with you.";
|
||||
if($parts[0] === 'user') notify_user($parts[1], $msg);
|
||||
else notify_group($parts[1], $msg);
|
||||
notify_waha('Shared', 'Password Entry', $p['title']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user