Added stash creation. Added dialog framework.
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user