mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
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:
@@ -209,9 +209,11 @@ class ThesisCreateController
|
||||
$nextNum = $this->handleTfeQueueFiles($thesisId, $qAudio, $folderPath, $filePrefix, $nextNum);
|
||||
$this->handleAnnexeQueueFiles($thesisId, $qAnnexe, $folderPath, $filePrefix);
|
||||
|
||||
// ── 5b. PeerTube video / audio uploads ────────────────────────────────
|
||||
$this->handlePeerTubeUpload($thesisId, $data['titre'], $files, 'peertube_video');
|
||||
$this->handlePeerTubeUpload($thesisId, $data['titre'], $files, 'peertube_audio');
|
||||
// ── 5b. PeerTube video / audio uploads (from FilePond queue) ──────────
|
||||
$qPTVideo = $this->extractFilesSubArray($queueFiles, 'peertube_video');
|
||||
$qPTAudio = $this->extractFilesSubArray($queueFiles, 'peertube_audio');
|
||||
$this->handlePeerTubeQueueFiles($thesisId, $data['titre'], $qPTVideo, 'video');
|
||||
$this->handlePeerTubeQueueFiles($thesisId, $data['titre'], $qPTAudio, 'audio');
|
||||
|
||||
// ── 6. Website URL — stored as thesis_files row ──────────────────────
|
||||
$this->handleWebsiteUrl($thesisId, $post);
|
||||
@@ -581,17 +583,19 @@ class ThesisCreateController
|
||||
}
|
||||
|
||||
/**
|
||||
* 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'.
|
||||
*/
|
||||
protected function handlePeerTubeUpload(int $thesisId, string $title, array $files, string $inputName): void
|
||||
protected 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;
|
||||
}
|
||||
|
||||
@@ -600,29 +604,37 @@ class ThesisCreateController
|
||||
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, // stored as the watch URL (no local file)
|
||||
basename($upload['name']),
|
||||
$upload['size'],
|
||||
$upload['type'] ?? 'application/octet-stream',
|
||||
null,
|
||||
null
|
||||
);
|
||||
error_log("ThesisCreateController: PeerTube upload OK → $watchUrl");
|
||||
} catch (\Throwable $e) {
|
||||
error_log('ThesisCreateController: PeerTube upload failed — ' . $e->getMessage());
|
||||
// Non-fatal: the thesis is already saved; admin can re-upload manually.
|
||||
try {
|
||||
$result = PeerTubeService::upload(
|
||||
$this->db,
|
||||
$uploads['tmp_name'][$i],
|
||||
$title,
|
||||
''
|
||||
);
|
||||
|
||||
// Store as peertube_ids:{uuid} so the embed template can extract the UUID
|
||||
$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("ThesisCreateController: PeerTube upload OK → " . $result['watchUrl']);
|
||||
} catch (\Throwable $e) {
|
||||
error_log('ThesisCreateController: PeerTube upload failed — ' . $e->getMessage());
|
||||
// Non-fatal: thesis already saved; admin can re-upload manually.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user