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:
Pontoporeia
2026-05-08 16:48:34 +02:00
parent 11e61226e2
commit 03c5fd217e
12 changed files with 658 additions and 4 deletions

15
TODO.md
View File

@@ -2,6 +2,19 @@
## Completed
- [x] PeerTube integration — two parallel systems (backup direct upload + PeerTube API)
- [x] `PeerTubeService.php` — credentials CRUD + OAuth2 password grant + multipart upload to `/api/v1/videos/upload`
- [x] Migration `021_peertube_settings.sql``peertube_settings` table (singleton) + `peertube_upload_enabled` feature flag (default 0 = disabled)
- [x] `actions/settings.php``peertube` section handler (toggle + credential save)
- [x] `admin/parametres.php` — PeerTube section UI (instance URL, username, password, channel ID, privacy)
- [x] `templates/admin/parametres.php` — PeerTube settings form between SMTP and admin account sections
- [x] `admin/partage/fichiers-fragment.php` — shows `<input type="file">` for video/audio when enabled, keeps TODO notice when disabled
- [x] `ThesisCreateController``handlePeerTubeUpload()` uploads video/audio to PeerTube, stores watch URL as `thesis_files` row
- [x] `ThesisEditController` — same `handlePeerTubeUpload()` method for edit workflow
- [x] `templates/public/tfe.php` — renders PeerTube iframe embed for files whose path contains `/videos/watch/`
- [x] `AdminLogger``logPeerTubeUpdate()` audit method
- [x] Direct file upload fallback: when `peertube_upload_enabled = 0`, standard `<input type="file">` + local storage works unchanged
- [x] Fix `just serve` — justfile shebang recipes (`deploy-env`, `reencrypt-password`) used space indentation instead of tabs, causing "extra leading whitespace" parse error
- [x] PDF 100 MB limit + bentopdf mention
@@ -16,7 +29,7 @@
- [x] Migration 020: add `sort_order` column, rename Autre → Etc. / Autre, add Image, set display order (Écriture · Image · Audio · Vidéo · Site web · Performance · Objet éditorial · Installation · Etc. / Autre)
- [x] `Database.php` format_types query uses `ORDER BY sort_order, id`
- [x] `fichiers-fragment.php` uses `ORDER BY sort_order, id`; Image/Vidéo/Audio IDs resolved via name map
- [ ] TODO: Vidéo + Audio — PeerTube API upload (notice shown in form for now)
- [x] TODO: Vidéo + Audio — PeerTube API upload (notice shown in form for now)
- [x] Combined Format + Fichiers into HTMX-swappable block
- [x] `partage/fichiers-fragment.php` — new combined fragment: format checkboxes + fichiers fieldset that adapts based on selected formats (upload inputs / URL fields / both)