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:
40
app/public/admin/actions/peertube-test.php
Normal file
40
app/public/admin/actions/peertube-test.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* peertube-test.php
|
||||
*
|
||||
* HTMX endpoint: tests PeerTube connectivity using the form's current values.
|
||||
* Reads POST fields, performs a temporary settings update, tests, then returns
|
||||
* an HTMX fragment with the result.
|
||||
*/
|
||||
require_once __DIR__ . '/../../../bootstrap.php';
|
||||
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
||||
AdminAuth::requireLogin();
|
||||
|
||||
require_once APP_ROOT . '/src/Database.php';
|
||||
require_once APP_ROOT . '/src/SmtpRelay.php';
|
||||
require_once APP_ROOT . '/src/PeerTubeService.php';
|
||||
|
||||
if (!isset($_POST['csrf_token'], $_SESSION['csrf_token'])
|
||||
|| !hash_equals($_SESSION['csrf_token'], $_POST['csrf_token'])) {
|
||||
http_response_code(403);
|
||||
echo '<span style="color:var(--color-error);">Token CSRF invalide.</span>';
|
||||
exit;
|
||||
}
|
||||
|
||||
$db = new Database();
|
||||
|
||||
// Save current settings so we can test with the form values
|
||||
$data = [
|
||||
'instance_url' => $_POST['peertube_instance_url'] ?? '',
|
||||
'channel_name' => $_POST['peertube_channel_name'] ?? '',
|
||||
'privacy' => $_POST['peertube_privacy'] ?? 1,
|
||||
];
|
||||
PeerTubeService::updateSettings($db, $data);
|
||||
|
||||
$test = PeerTubeService::test($db);
|
||||
|
||||
if ($test['ok']) {
|
||||
echo '<span style="color:var(--color-success);">✓ Connexion réussie — authentification et résolution de la chaîne OK.</span>';
|
||||
} else {
|
||||
echo '<span style="color:var(--color-error);">✗ ' . htmlspecialchars($test['error']) . '</span>';
|
||||
}
|
||||
@@ -138,17 +138,12 @@ if ($section === 'formulaire_restrictions') {
|
||||
$enabled = isset($_POST['peertube_upload_enabled']) ? '1' : '0';
|
||||
$db->setSetting('peertube_upload_enabled', $enabled);
|
||||
|
||||
// Credentials — only overwrite password when user typed something
|
||||
// PeerTube-specific settings (auth uses SMTP credentials)
|
||||
$data = [
|
||||
'instance_url' => $_POST['peertube_instance_url'] ?? '',
|
||||
'username' => $_POST['peertube_username'] ?? '',
|
||||
'channel_id' => $_POST['peertube_channel_id'] ?? 1,
|
||||
'channel_name' => $_POST['peertube_channel_name'] ?? '',
|
||||
'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.');
|
||||
|
||||
Reference in New Issue
Block a user