mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
refactor: merge video/audio FilePond pools into TFE input
- Remove separate video/audio/peertube_video/peertube_audio pools from UI - TFE pool now accepts all file types including video/audio - When PeerTube is enabled, video/audio dropped into TFE pool auto-upload to PeerTube (process.php detects MIME and uploads immediately) - PeerTube return IDs now encode type: peertube:video:UUID or peertube:audio:UUID - load.php returns placeholder SVG for PeerTube files so they appear in FilePond - Edit mode: all existing files (including PeerTube) shown in TFE FilePond pool - Remove legacy video/audio/peertube_* handling from both controllers - Remove unused vide/audio/peertube_* entries from JS QUEUE_CONFIG
This commit is contained in:
@@ -45,10 +45,19 @@ $filePath = $fileRow['file_path'] ?? '';
|
||||
$fileName = $fileRow['file_name'] ?? basename($filePath);
|
||||
$mimeType = $fileRow['mime_type'] ?? 'application/octet-stream';
|
||||
|
||||
// ── Skip PeerTube and website entries (no actual file) ───────────────────
|
||||
// ── PeerTube entries: return a placeholder SVG blob so FilePond can display them ─┐
|
||||
if (str_starts_with($filePath, 'peertube_ids:')) {
|
||||
http_response_code(404);
|
||||
die('Fichier PeerTube — pas de flux direct.');
|
||||
$uuid = substr($filePath, strlen('peertube_ids:'));
|
||||
$isVideo = ($fileRow['file_type'] ?? '') === 'video';
|
||||
$svg = $isVideo
|
||||
? '<svg xmlns="http://www.w3.org/2000/svg" width="180" height="120" viewBox="0 0 180 120"><rect width="180" height="120" fill="#1a1a2e"/><polygon points="70,35 70,85 125,60" fill="#e94560"/><text x="90" y="110" text-anchor="middle" font-family="sans-serif" font-size="10" fill="#aaa">PeerTube ' . htmlspecialchars($uuid) . '</text></svg>'
|
||||
: '<svg xmlns="http://www.w3.org/2000/svg" width="180" height="120" viewBox="0 0 180 120"><rect width="180" height="120" fill="#1a1a2e"/><circle cx="55" cy="60" r="20" fill="none" stroke="#4ecca3" stroke-width="3"/><line x1="72" y1="48" x2="95" y2="38" stroke="#4ecca3" stroke-width="3"/><line x1="72" y1="60" x2="110" y2="60" stroke="#4ecca3" stroke-width="3"/><line x1="72" y1="72" x2="95" y2="82" stroke="#4ecca3" stroke-width="3"/><text x="90" y="110" text-anchor="middle" font-family="sans-serif" font-size="10" fill="#aaa">PeerTube ' . htmlspecialchars($uuid) . '</text></svg>';
|
||||
header('Content-Type: image/svg+xml');
|
||||
header('Content-Length: ' . strlen($svg));
|
||||
header('Content-Disposition: inline; filename="peertube.svg"');
|
||||
header('Cache-Control: no-cache');
|
||||
echo $svg;
|
||||
exit;
|
||||
}
|
||||
if (str_starts_with($filePath, 'http://') || str_starts_with($filePath, 'https://')) {
|
||||
http_response_code(404);
|
||||
|
||||
@@ -209,11 +209,14 @@ chmod($targetPath, 0644);
|
||||
error_log('[filepond:process] File saved to tmp | file_id=' . $fileId . ' | path=' . $targetPath);
|
||||
|
||||
// ── PeerTube: upload immediately (don't wait for form submit) ────────────
|
||||
$isPeerTube = str_starts_with($queueType, 'peertube_');
|
||||
if ($isPeerTube) {
|
||||
// Handles both dedicated peertube_* queues (legacy) and video/audio in the TFE pool
|
||||
$isPeerTubeQueue = str_starts_with($queueType, 'peertube_');
|
||||
$isTfeAv = ($queueType === 'tfe' && preg_match('/^(video|audio)\//', $mimeType));
|
||||
$shouldPeerTube = $isPeerTubeQueue || $isTfeAv;
|
||||
if ($shouldPeerTube) {
|
||||
require_once APP_ROOT . '/src/PeerTubeService.php';
|
||||
if (PeerTubeService::isEnabled(new Database())) {
|
||||
$ptFileType = ($queueType === 'peertube_video') ? 'video' : 'audio';
|
||||
$ptFileType = preg_match('/^video\//', $mimeType) ? 'video' : 'audio';
|
||||
try {
|
||||
$result = PeerTubeService::upload(
|
||||
new Database(),
|
||||
@@ -223,7 +226,8 @@ if ($isPeerTube) {
|
||||
''
|
||||
);
|
||||
// Return a special ID prefix so the controller knows not to look in tmp/
|
||||
$fileId = 'peertube:' . $result['uuid'];
|
||||
// Format: peertube:video:UUID or peertube:audio:UUID
|
||||
$fileId = 'peertube:' . $ptFileType . ':' . $result['uuid'];
|
||||
// Clean up temp file — PeerTube has its own copy now
|
||||
@unlink($targetPath);
|
||||
@rmdir($tmpDir);
|
||||
@@ -239,11 +243,14 @@ if ($isPeerTube) {
|
||||
die('Erreur lors du téléversement vers PeerTube.');
|
||||
}
|
||||
} else {
|
||||
// PeerTube not enabled — reject the upload
|
||||
@unlink($targetPath);
|
||||
@rmdir($tmpDir);
|
||||
http_response_code(503);
|
||||
die('PeerTube n\'est pas activé.');
|
||||
// PeerTube not enabled — save to disk normally (only for tfe pool, not dedicated peertube queues)
|
||||
if ($isPeerTubeQueue) {
|
||||
@unlink($targetPath);
|
||||
@rmdir($tmpDir);
|
||||
http_response_code(503);
|
||||
die('PeerTube n\'est pas activé.');
|
||||
}
|
||||
// For TFE pool, fall through to normal disk save below
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ if ($_SERVER['REQUEST_METHOD'] !== 'DELETE') {
|
||||
$fileId = trim(file_get_contents('php://input'));
|
||||
|
||||
// PeerTube files have a special prefix; nothing to clean up locally
|
||||
// Format: peertube:video:UUID or peertube:audio:UUID
|
||||
if (str_starts_with($fileId, 'peertube:')) {
|
||||
// PeerTube files are already uploaded; we don't delete them from PeerTube on revert
|
||||
// (the user might still submit and associate them)
|
||||
|
||||
Reference in New Issue
Block a user