<?php
include_once __DIR__ . '/../config/index.php';
include_once __DIR__ . '/../includes/notify_telegram.php';

// Server-side Telegram-notificatie endpoint
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['message'])) {
    $message = $_POST['message'];
    $result = sendTGNotification($message);
    if ($result === FALSE) {
        echo json_encode(array("status" => "error", "message" => "Notification failed"));
    } else {
        echo json_encode(array("status" => "success", "message" => "Notification sent"));
    }
} else {
    echo json_encode(array("status" => "error", "message" => "Invalid request"));
}
?>
