feat: add notifications_enabled toggle for users (web + Android)

This commit is contained in:
2026-06-13 17:28:59 -04:00
parent 81f61ff96e
commit ec38afe3e9
11 changed files with 352 additions and 8 deletions

View File

@@ -452,6 +452,15 @@ class ApiController
if (!empty($breaches)) {
$userIds = $serverModel->getAccessibleUserIds((int) $server['id']);
$db = \ServerManager\Core\Database::getInstance();
$placeholders = implode(',', array_fill(0, count($userIds), '?'));
$enabled = $db->fetchCol(
"SELECT id FROM users WHERE id IN ({$placeholders}) AND notifications_enabled = 1",
$userIds
);
$userIds = $enabled;
$notificationModel = new Notification();
$fcm = new FCMService();
foreach ($breaches as $b) {
@@ -572,6 +581,7 @@ class ApiController
'email' => $user['email'],
'role' => $user['role'],
'created_at' => $user['created_at'],
'notifications_enabled' => (bool) ($user['notifications_enabled'] ?? true),
],
]);
}
@@ -597,6 +607,10 @@ class ApiController
$updateData = ['email' => $input['email']];
if (isset($input['notifications_enabled'])) {
$updateData['notifications_enabled'] = $input['notifications_enabled'] ? 1 : 0;
}
if (!empty($input['new_password'])) {
if (strlen($input['new_password']) < 8) {
$this->view->json([

View File

@@ -194,6 +194,12 @@ class AuthController
$updateData = ['email' => $_POST['email']];
if (isset($_POST['notifications_enabled'])) {
$updateData['notifications_enabled'] = 1;
} else {
$updateData['notifications_enabled'] = 0;
}
if (!empty($_POST['new_password'])) {
$updateData['password'] = $_POST['new_password'];
}