<?php
declare(strict_types=1);
require_once __DIR__.'/../auth.php';require_login('../login.php');
if(session_status()===PHP_SESSION_ACTIVE)@session_write_close();
require_once __DIR__.'/../db_bootstrap.php';require_once __DIR__.'/../device_admin_alerts_lib.php';
header('Content-Type: application/json; charset=utf-8');
try{
  $conn=ensure_db(true);$requests=[];
  foreach(array_filter(array_map('trim',explode(',',(string)($_GET['items']??'')))) as $token){if(preg_match('/^(routers|sectors|receivers):(\d+)$/',$token,$m))$requests[]=['group'=>$m[1],'id'=>(int)$m[2]];}
  echo json_encode(['ok'=>true,'muted'=>device_admin_alert_statuses($conn,array_slice($requests,0,100)),'settings'=>device_admin_alerts_settings($conn)],JSON_UNESCAPED_UNICODE);
}catch(Throwable $e){http_response_code(500);echo json_encode(['ok'=>false],JSON_UNESCAPED_UNICODE);}

