<?php

require_once '../element/connection.php';

if (!isset($_SESSION['user_id'])) {
    exit();
}

$ticket_id = intval($_POST['ticket_id']);
$typing = $_POST['typing'] === 'true' ? 1 : 0;
$user_id = $_SESSION['user_id'];

// Store typing status in session
$_SESSION['typing_' . $ticket_id] = [
    'user_id' => $user_id,
    'typing' => $typing,
    'timestamp' => time()
];

echo json_encode(['success' => true]);
?>