Complete backend for SprintChat Hub migration: - Messages: send, edit, delete, list (paginated cursor), thread, search - Files: upload (multipart), download, thumbnail, info, list - Users: get, getByIds, search, status (online detection) - Reactions: add, remove, list (grouped by emoji) - Pins: pin, unpin, list (with message content) - Channel stats: member/message/pinned/unread counts 4 new DB tables: Hub_Messages, Hub_Files, Hub_Reactions, Hub_PinnedPosts 21 new endpoints added to PUBLIC_ROUTES Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* GET /api/hub/files/info.php
|
|
*
|
|
* Get file metadata by ID.
|
|
*
|
|
* Query params:
|
|
* FileID int REQUIRED
|
|
*
|
|
* Response: { OK: true, File: { ... } }
|
|
*/
|
|
|
|
require_once __DIR__ . '/../../helpers.php';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
|
|
jsonResponse(['OK' => false, 'ERROR' => 'method_not_allowed'], 405);
|
|
}
|
|
|
|
$fileId = (int) ($_GET['FileID'] ?? 0);
|
|
if ($fileId <= 0) jsonResponse(['OK' => false, 'ERROR' => 'file_id_required']);
|
|
|
|
$record = queryOne("SELECT * FROM Hub_Files WHERE ID = ?", [$fileId]);
|
|
if (!$record) jsonResponse(['OK' => false, 'ERROR' => 'file_not_found']);
|
|
|
|
jsonResponse([
|
|
'OK' => true,
|
|
'File' => [
|
|
'ID' => (int) $record['ID'],
|
|
'MessageID' => $record['MessageID'] ? (int) $record['MessageID'] : null,
|
|
'ChannelID' => (int) $record['ChannelID'],
|
|
'UploaderAddress' => $record['UploaderAddress'],
|
|
'FileName' => $record['FileName'],
|
|
'FileSize' => (int) $record['FileSize'],
|
|
'MimeType' => $record['MimeType'],
|
|
'DownloadURL' => baseUrl() . '/' . $record['StoragePath'],
|
|
'ThumbnailURL' => $record['ThumbnailPath'] ? baseUrl() . '/' . $record['ThumbnailPath'] : null,
|
|
'CreatedAt' => toISO8601($record['CreatedAt']),
|
|
],
|
|
]);
|