feat: delete lesson videos from Bunny
This commit is contained in:
@@ -114,6 +114,10 @@ export async function getBunnyVideo(videoId: string) {
|
||||
return toVideo(await response.json() as BunnyApiVideo);
|
||||
}
|
||||
|
||||
export async function deleteBunnyVideo(videoId: string) {
|
||||
await bunnyRequest(`/videos/${encodeURIComponent(videoId)}`, { method: 'DELETE' });
|
||||
}
|
||||
|
||||
export function signedBunnyEmbedUrl(videoId: string, validitySeconds = config.BUNNY_EMBED_TOKEN_TTL_SECONDS) {
|
||||
const { libraryId, embedTokenKey } = getBunnyConfiguration();
|
||||
const expires = Math.floor(Date.now() / 1000) + validitySeconds;
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
BunnyConfigurationError,
|
||||
BunnyRequestError,
|
||||
createBunnyVideo,
|
||||
deleteBunnyVideo,
|
||||
getBunnyVideo,
|
||||
isBunnyConfigured,
|
||||
uploadBunnyVideo,
|
||||
@@ -123,4 +124,15 @@ export const mediaRoutes: FastifyPluginAsync = async (app) => {
|
||||
return providerError(reply, error);
|
||||
}
|
||||
});
|
||||
|
||||
app.delete('/bunny/videos/:videoId', manageAccess, async (request, reply) => {
|
||||
const { videoId } = videoParamsSchema.parse(request.params);
|
||||
try {
|
||||
await deleteBunnyVideo(videoId);
|
||||
await recordAudit({ actorId: request.user.id, action: 'media.video.deleted', subjectType: 'video', subjectId: videoId, ipAddress: request.ip });
|
||||
return reply.code(204).send();
|
||||
} catch (error) {
|
||||
return providerError(reply, error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user