Added stash creation. Added dialog framework.
This commit is contained in:
@@ -47,6 +47,7 @@ export async function login(credentials, userIp) {
|
||||
const { user, stashes } = await fetchUser(credentials.username.trim(), {
|
||||
email: true,
|
||||
raw: true,
|
||||
includeStashes: true,
|
||||
}).catch(() => {
|
||||
throw new HttpError('Username or password incorrect', 401);
|
||||
});
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -53,7 +53,7 @@ export async function fetchUser(userId, options = {}, reqUser) {
|
||||
const stashes = await knex('stashes')
|
||||
.where('user_id', user.id)
|
||||
.modify((builder) => {
|
||||
if (reqUser?.id !== user.id) {
|
||||
if (reqUser?.id !== user.id && !options.includeStashes) {
|
||||
builder.where('public', true);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
} from './auth.js';
|
||||
|
||||
import {
|
||||
fetchUserApi
|
||||
fetchUserApi,
|
||||
} from './users.js';
|
||||
|
||||
import {
|
||||
|
||||
Reference in New Issue
Block a user