fix: supprimer les vidéos PeerTube lors de la suppression d'un TFE

- Ajout de PeerTubeService::deleteVideo() qui appelle DELETE /api/v1/videos/{uuid}
- deleteThesisFileToTrash() appelle maintenant deleteVideo() pour les fichiers peertube_ids:
- hardDeleteThesis() supprime aussi les vidéos PeerTube associées
This commit is contained in:
Pontoporeia
2026-06-08 17:24:07 +02:00
parent 312d9eab0e
commit a2092b58a7
4 changed files with 54 additions and 10 deletions

View File

@@ -265,6 +265,43 @@ class PeerTubeService
return rtrim($s['instance_url'], '/') . '/videos/watch/' . $uuid;
}
// -------------------------------------------------------------------------
// Delete
// -------------------------------------------------------------------------
/**
* Delete a video from PeerTube by UUID or shortUUID.
*
* DELETE /api/v1/videos/{uuid}
*
* @return bool true on success, false on failure
*/
public static function deleteVideo(Database $db, string $uuid): bool
{
$s = self::getSettings($db);
if ($s['instance_url'] === '') {
error_log('PeerTubeService::deleteVideo: instance not configured');
return false;
}
try {
$token = self::obtainToken($s);
$url = rtrim($s['instance_url'], '/') . '/api/v1/videos/' . urlencode($uuid);
$resp = self::httpRequest($url, 'DELETE', [
'headers' => ['Authorization' => 'Bearer ' . $token],
'timeout' => 30,
]);
if ($resp['status'] === 204 || $resp['status'] === 200) {
error_log('PeerTubeService: deleted video ' . $uuid);
return true;
}
error_log('PeerTubeService::deleteVideo: unexpected status ' . $resp['status'] . ' for ' . $uuid . ' | body=' . substr($resp['body'], 0, 300));
return false;
} catch (\Throwable $e) {
error_log('PeerTubeService::deleteVideo failed: ' . $e->getMessage());
return false;
}
}
// -------------------------------------------------------------------------
// Channel resolution
// -------------------------------------------------------------------------