<?php
ob_start();
header('Content-Type: application/json');
require_once '../config.php';

$user_id = $_SESSION['user_id'] ?? 0;
$id = intval($_POST['id'] ?? 0);

if ($user_id && $id) {
    $db->query("UPDATE notifications SET is_read = 1 WHERE id = $id AND user_id IN (0, $user_id)");
}

echo json_encode(['code' => 0]);
exit;