feat: PeerTube integration — alternate audio/video labels, FilePond pools, shared SMTP credentials, channel by name, test button, resumable upload, embed improvements, fix alt labels/curl_close/deprecation

This commit is contained in:
Pontoporeia
2026-05-19 00:08:06 +02:00
parent 28ef35dce5
commit 83a5a508ea
18 changed files with 748 additions and 261 deletions
+43 -32
View File
@@ -437,9 +437,11 @@ class ThesisEditController
$this->handleAnnexeFiles($thesisId, $files['annexes'], $folderPath, $filePrefix, $post);
}
// ── PeerTube video / audio uploads ────────────────────────────────────
$this->handlePeerTubeUpload($thesisId, trim($post['titre'] ?? ''), $files, 'peertube_video');
$this->handlePeerTubeUpload($thesisId, trim($post['titre'] ?? ''), $files, 'peertube_audio');
// ── PeerTube video / audio uploads (from FilePond queue) ──────────────
$qPTVideo = $this->extractFilesSubArray($queueFiles, 'peertube_video');
$qPTAudio = $this->extractFilesSubArray($queueFiles, 'peertube_audio');
$this->handlePeerTubeQueueFiles($thesisId, trim($post['titre'] ?? ''), $qPTVideo, 'video');
$this->handlePeerTubeQueueFiles($thesisId, trim($post['titre'] ?? ''), $qPTAudio, 'audio');
// ── Website URL — add or update ──────────────────────────────────────
$this->handleWebsiteUrl($thesisId, $post);
@@ -571,17 +573,19 @@ class ThesisEditController
}
/**
* Upload a video or audio file to PeerTube when the feature is enabled.
* Upload PeerTube video/audio files from FilePond queue.
*
* @param int $thesisId Thesis to attach the result to.
* @param string $title Title to use on PeerTube.
* @param array $files $_FILES array.
* @param string $inputName 'peertube_video' or 'peertube_audio'.
* Files arrive via PHP's nested $_FILES structure from
* <input name="queue_file[peertube_video][]">.
*
* @param int $thesisId Thesis to attach the results to.
* @param string $title Title to use on PeerTube.
* @param array|null $uploads Flat $_FILES-style array from extractFilesSubArray().
* @param string $fileType 'video' or 'audio'.
*/
private function handlePeerTubeUpload(int $thesisId, string $title, array $files, string $inputName): void
private function handlePeerTubeQueueFiles(int $thesisId, string $title, ?array $uploads, string $fileType): void
{
$upload = $files[$inputName] ?? null;
if (!$upload || !isset($upload['error']) || $upload['error'] !== UPLOAD_ERR_OK) {
if (!$uploads || !is_array($uploads['name'] ?? null)) {
return;
}
@@ -590,28 +594,35 @@ class ThesisEditController
return;
}
try {
$watchUrl = PeerTubeService::upload(
$this->db,
$upload['tmp_name'],
$title,
''
);
$count = count($uploads['name']);
for ($i = 0; $i < $count; $i++) {
if (($uploads['error'][$i] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_OK) {
continue;
}
$fileType = str_contains($inputName, 'audio') ? 'audio' : 'video';
$this->db->insertThesisFile(
$thesisId,
$fileType,
$watchUrl,
basename($upload['name']),
$upload['size'],
$upload['type'] ?? 'application/octet-stream',
null,
null
);
error_log("ThesisEditController: PeerTube upload OK → $watchUrl");
} catch (\Throwable $e) {
error_log('ThesisEditController: PeerTube upload failed — ' . $e->getMessage());
try {
$result = PeerTubeService::upload(
$this->db,
$uploads['tmp_name'][$i],
$title,
''
);
$storedPath = 'peertube_ids:' . $result['uuid'];
$this->db->insertThesisFile(
$thesisId,
$fileType,
$storedPath,
basename($uploads['name'][$i]),
$uploads['size'][$i],
$uploads['type'][$i] ?? 'application/octet-stream',
null,
null
);
error_log("ThesisEditController: PeerTube upload OK → " . $result['watchUrl']);
} catch (\Throwable $e) {
error_log('ThesisEditController: PeerTube upload failed — ' . $e->getMessage());
}
}
}