Fix video controller permissions

This commit is contained in:
2025-11-03 12:27:30 +01:00
parent c1b243df9c
commit 572ddc69ad
3 changed files with 16 additions and 8 deletions

View File

@@ -13,8 +13,8 @@ import { series } from "./controllers/shows/series";
import { showsH } from "./controllers/shows/shows";
import { staffH } from "./controllers/staff";
import { studiosH } from "./controllers/studios";
import { videosH } from "./controllers/videos";
import type { KError } from "./models/error";
import { videosReadH, videosWriteH } from "./controllers/videos";
import { KError } from "./models/error";
export const base = new Elysia({ name: "base" })
.onError(({ code, error }) => {
@@ -90,7 +90,8 @@ export const handlers = new Elysia({ prefix })
.use(imagesH)
.use(watchlistH)
.use(historyH)
.use(nextup),
.use(nextup)
.use(videosReadH),
)
.guard(
{
@@ -104,5 +105,5 @@ export const handlers = new Elysia({ prefix })
// },
permissions: ["core.write"],
},
(app) => app.use(videosH).use(seed),
(app) => app.use(videosWriteH).use(seed),
);

View File

@@ -439,10 +439,9 @@ function getNextVideoEntry({
.as("next");
}
export const videosH = new Elysia({ prefix: "/videos", tags: ["videos"] })
export const videosReadH = new Elysia({ prefix: "/videos", tags: ["videos"] })
.model({
video: Video,
"created-videos": t.Array(CreatedVideo),
error: t.Object({}),
})
.use(auth)
@@ -483,7 +482,7 @@ export const videosH = new Elysia({ prefix: "/videos", tags: ["videos"] })
message: `No video found with id or slug '${id}'`,
});
}
return video;
return video as any;
},
{
detail: {
@@ -806,6 +805,14 @@ export const videosH = new Elysia({ prefix: "/videos", tags: ["videos"] })
},
},
)
export const videosWriteH = new Elysia({ prefix: "/videos", tags: ["videos"] })
.model({
video: Video,
"created-videos": t.Array(CreatedVideo),
error: t.Object({}),
})
.use(auth)
.post(
"",
async ({ body, status }) => {