<?php
// Filename: api_hide_announcement.php
require 'config.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_SESSION['user_id'])) {
    $input = json_decode(file_get_contents('php://input'), true);
    $aid = $input['announcement_id'] ?? 0;
    $uid = $_SESSION['user_id'];

    if ($aid) {
        try {
            $stmt = $pdo->prepare("INSERT IGNORE INTO announcement_hides (user_id, announcement_id) VALUES (?, ?)");
            $stmt->execute([$uid, $aid]);
            echo json_encode(['success' => true]);
        } catch (Exception $e) {
            echo json_encode(['success' => false]);
        }
    }
}
?>

