Added stash creation. Added dialog framework.

This commit is contained in:
2024-03-26 04:14:42 +01:00
parent 9de289a0fb
commit 68b9658ba6
9 changed files with 377 additions and 82 deletions

View File

@@ -22,9 +22,9 @@ export function curateStash(stash, assets = {}) {
primary: stash.primary,
public: stash.public,
createdAt: stash.created_at,
stashedScenes: stash.stashed_scenes || null,
stashedMovies: stash.stashed_movies || null,
stashedActors: stash.stashed_actors || null,
stashedScenes: stash.stashed_scenes ?? null,
stashedMovies: stash.stashed_movies ?? null,
stashedActors: stash.stashed_actors ?? null,
user: assets.user ? {
id: assets.user.id,
username: assets.user.username,
@@ -99,6 +99,22 @@ export async function createStash(newStash, sessionUser) {
throw new HttpError('You are not authenthicated', 401);
}
if (!newStash.name) {
throw new HttpError('Stash name required', 400);
}
if (newStash.name.length < config.stashes.nameLength[0]) {
throw new HttpError('Stash name is too short', 400);
}
if (newStash.name.length > config.stashes.nameLength[1]) {
throw new HttpError('Stash name is too long', 400);
}
if (!config.stashes.namePattern.test(newStash.name)) {
throw new HttpError('Stash name contains invalid characters', 400);
}
try {
const stash = await knex('stashes')
.insert(curateStashEntry(newStash, sessionUser))