Init Git Prod Mars 2026

This commit is contained in:
Oleg Barykin committed 2026-03-05 10:25:39 +01:00
commit d81efe93b1
362 files changed
+86627

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
<?php
// /messages/api/close_conversation.php
declare(strict_types=1);
require_once __DIR__ . '/../_bootstrap.php';
header('Content-Type: application/json; charset=utf-8');
if (!hash_equals($_SESSION['_csrf'] ?? '', $_POST['_csrf'] ?? '')) {
json_response(['error' => 'csrf'], 419);
}
$role = $GLOBALS['MESSAGES_CTX']['role'];
$meId = $GLOBALS['MESSAGES_CTX']['me_id'];
$convId = (int)($_POST['conversation_id'] ?? 0);
$close = (int)($_POST['close'] ?? 1);
if ($convId <= 0) json_response(['error' => 'bad_params'], 400);
// Vérifie l'accès (participant à la conversation)
assert_conversation_access($pdo, $convId, $role, $meId);
// Met à jour le statut
if ($close) {
$pdo->prepare("UPDATE conversations SET status='closed', closed_at=NOW() WHERE id=?")->execute([$convId]);
} else {
$pdo->prepare("UPDATE conversations SET status='open', closed_at=NULL WHERE id=?")->execute([$convId]);
}
json_response(['ok' => true, 'status' => $close ? 'closed' : 'open']);