mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Reserve the random
slug
This commit is contained in:
parent
46570410ea
commit
b6f996139f
@ -13,6 +13,7 @@ import { conflictUpdateAllExcept } from "~/db/schema/utils";
|
||||
import type { SeedMovie } from "~/models/movie";
|
||||
import { processOptImage } from "./images";
|
||||
import { guessNextRefresh } from "./refresh";
|
||||
import { KErrorT } from "~/models/error";
|
||||
|
||||
type Show = typeof shows.$inferInsert;
|
||||
type ShowTrans = typeof showTranslations.$inferInsert;
|
||||
@ -29,11 +30,18 @@ export type SeedMovieResponse = typeof SeedMovieResponse.static;
|
||||
|
||||
export const seedMovie = async (
|
||||
seed: SeedMovie,
|
||||
): Promise<
|
||||
SeedMovieResponse & { status: "Created" | "OK" | "Conflict" }
|
||||
> => {
|
||||
): Promise<SeedMovieResponse & {
|
||||
status: "Created" | "OK" | "Conflict";
|
||||
}> => {
|
||||
const { translations, videos: vids, ...bMovie } = seed;
|
||||
|
||||
if (seed.slug === "random") {
|
||||
if (seed.airDate === null) {
|
||||
throw new KErrorT("`random` is a reserved slug. Use something else.");
|
||||
}
|
||||
seed.slug = `random-${getYear(seed.airDate)}`;
|
||||
}
|
||||
|
||||
const ret = await db.transaction(async (tx) => {
|
||||
const movie: Show = {
|
||||
kind: "movie",
|
||||
|
Loading…
x
Reference in New Issue
Block a user