mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
feat: dual upload system — direct file storage + PeerTube API integration
Adds a parallel PeerTube upload system behind a feature flag (disabled by default until upload quota is granted). When disabled, the existing direct file upload path works unchanged. Files: - src/PeerTubeService.php — credential storage (encrypted), OAuth2 token retrieval, multipart upload to /api/v1/videos/upload - migrations/021_peertube_settings.sql — peertube_settings singleton table + peertube_upload_enabled site_setting (default 0) - admin/actions/settings.php — peertube section handler - admin/parametres.php / templates/admin/parametres.php — PeerTube UI section - partage/fichiers-fragment.php — shows file inputs when enabled, TODO notice otherwise - ThesisCreateController / ThesisEditController — handlePeerTubeUpload() - tfe.php — PeerTube iframe embed detection - AdminLogger — logPeerTubeUpdate()
This commit is contained in:
@@ -12,6 +12,7 @@ if (!isset($_POST['csrf_token'], $_SESSION['csrf_token'])
|
||||
|
||||
require_once APP_ROOT . '/src/Database.php';
|
||||
require_once APP_ROOT . '/src/SmtpRelay.php';
|
||||
require_once APP_ROOT . '/src/PeerTubeService.php';
|
||||
require_once APP_ROOT . '/src/AdminLogger.php';
|
||||
$db = new Database();
|
||||
$logger = AdminLogger::make();
|
||||
@@ -70,6 +71,25 @@ if ($section === 'formulaire') {
|
||||
$_SESSION['_flash_smtp_field'] = $test['field'];
|
||||
}
|
||||
}
|
||||
} elseif ($section === 'peertube') {
|
||||
// Feature flag
|
||||
$enabled = isset($_POST['peertube_upload_enabled']) ? '1' : '0';
|
||||
$db->setSetting('peertube_upload_enabled', $enabled);
|
||||
|
||||
// Credentials — only overwrite password when user typed something
|
||||
$data = [
|
||||
'instance_url' => $_POST['peertube_instance_url'] ?? '',
|
||||
'username' => $_POST['peertube_username'] ?? '',
|
||||
'channel_id' => $_POST['peertube_channel_id'] ?? 1,
|
||||
'privacy' => $_POST['peertube_privacy'] ?? 1,
|
||||
];
|
||||
$pwd = $_POST['peertube_password'] ?? '';
|
||||
if ($pwd !== '') {
|
||||
$data['password'] = $pwd;
|
||||
}
|
||||
PeerTubeService::updateSettings($db, $data);
|
||||
$logger->logPeerTubeUpdate($enabled === '1');
|
||||
App::flash('success', 'Paramètres PeerTube mis à jour.');
|
||||
} else {
|
||||
App::flash('error', "Section inconnue.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user