Upgraded dependencies, bumped to Node 24.
This commit is contained in:
+38
-27
@@ -1,11 +1,11 @@
|
||||
import config from 'config';
|
||||
import { CronJob } from 'cron';
|
||||
|
||||
import { knexOwner as knex } from './knex.js';
|
||||
import { indexApi } from './manticore.js';
|
||||
import { HttpError } from './errors.js';
|
||||
import slugify from './utils/slugify.js';
|
||||
import { knexOwner as knex } from './knex.js';
|
||||
import initLogger from './logger.js';
|
||||
import { indexApi } from './manticore.js';
|
||||
import slugify from './utils/slugify.js';
|
||||
|
||||
const logger = initLogger();
|
||||
|
||||
@@ -29,12 +29,14 @@ export function curateStash(stash, assets = {}) {
|
||||
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,
|
||||
avatar: `/media/avatars/${assets.user.id}_${assets.user.username}.png`,
|
||||
createdAt: assets.user.created_at,
|
||||
} : null,
|
||||
user: assets.user
|
||||
? {
|
||||
id: assets.user.id,
|
||||
username: assets.user.username,
|
||||
avatar: `/media/avatars/${assets.user.id}_${assets.user.username}.png`,
|
||||
createdAt: assets.user.created_at,
|
||||
}
|
||||
: null,
|
||||
comment: stash.comment,
|
||||
meta: stash.meta,
|
||||
};
|
||||
@@ -81,7 +83,8 @@ export async function fetchStashById(stashIdOrSlug, sessionUser) {
|
||||
.where((builder) => {
|
||||
if (typeof stashIdOrSlug === 'number') {
|
||||
builder.where('id', stashIdOrSlug);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
builder
|
||||
.where('slug', stashIdOrSlug)
|
||||
.where('user_id', sessionUser.id);
|
||||
@@ -99,7 +102,8 @@ export async function fetchStashByUsernameAndSlug(usernameOrId, stashSlug, sessi
|
||||
.where((builder) => {
|
||||
if (typeof usernameOrId === 'number') {
|
||||
builder.where('id', usernameOrId);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
builder.where('username', usernameOrId);
|
||||
}
|
||||
})
|
||||
@@ -125,9 +129,9 @@ export async function fetchUserStashes(usernameOrId, reqUser) {
|
||||
const userId = typeof usernameOrId === 'number'
|
||||
? usernameOrId
|
||||
: await knex('users')
|
||||
.where('username', usernameOrId)
|
||||
.first()
|
||||
.then((user) => user?.id);
|
||||
.where('username', usernameOrId)
|
||||
.first()
|
||||
.then((user) => user?.id);
|
||||
|
||||
if (!userId) {
|
||||
throw new HttpError(`Could not find user '${usernameOrId}'`);
|
||||
@@ -214,7 +218,8 @@ export async function createStash(newStash, sessionUser) {
|
||||
const curatedStash = curateStash(stash, { user: sessionUser });
|
||||
|
||||
return curatedStash;
|
||||
} catch (error) {
|
||||
}
|
||||
catch (error) {
|
||||
if (error.routine === '_bt_check_unique') {
|
||||
throw new HttpError('Stash name should be unique', 409);
|
||||
}
|
||||
@@ -245,7 +250,8 @@ export async function updateStash(stashIdOrSlug, updatedStash, sessionUser) {
|
||||
.where((builder) => {
|
||||
if (typeof stashIdOrSlug === 'number') {
|
||||
builder.where('id', stashIdOrSlug);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
builder.where('slug', stashIdOrSlug);
|
||||
}
|
||||
})
|
||||
@@ -258,7 +264,8 @@ export async function updateStash(stashIdOrSlug, updatedStash, sessionUser) {
|
||||
}
|
||||
|
||||
return curateStash(stash);
|
||||
} catch (error) {
|
||||
}
|
||||
catch (error) {
|
||||
if (error.routine === '_bt_check_unique') {
|
||||
throw new HttpError('Stash name should be unique', 409);
|
||||
}
|
||||
@@ -322,7 +329,7 @@ export async function stashActor(actorId, stashId, sessionUser) {
|
||||
.returning('*');
|
||||
|
||||
await indexApi.replace({
|
||||
index: 'actors_stashed',
|
||||
table: 'actors_stashed',
|
||||
id: stashed.id,
|
||||
doc: {
|
||||
actor_id: actorId,
|
||||
@@ -338,7 +345,8 @@ export async function stashActor(actorId, stashId, sessionUser) {
|
||||
|
||||
// return fetchDomainStashes('actor', actorId, sessionUser);
|
||||
return curateStashed(stashed);
|
||||
} catch (error) {
|
||||
}
|
||||
catch (error) {
|
||||
if (error.routine === '_bt_check_unique') {
|
||||
throw new HttpError(`Actor ${actorId} is already stashed in '${stash.name}'`, 409);
|
||||
}
|
||||
@@ -375,7 +383,7 @@ export async function unstashActor(actorId, stashId, sessionUser) {
|
||||
|
||||
try {
|
||||
await indexApi.callDelete({
|
||||
index: 'actors_stashed',
|
||||
table: 'actors_stashed',
|
||||
query: {
|
||||
bool: {
|
||||
must: [
|
||||
@@ -386,7 +394,8 @@ export async function unstashActor(actorId, stashId, sessionUser) {
|
||||
},
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
@@ -422,7 +431,7 @@ export async function stashScene(sceneId, stashId, sessionUser) {
|
||||
.returning('*');
|
||||
|
||||
await indexApi.replace({
|
||||
index: 'scenes_stashed',
|
||||
table: 'scenes_stashed',
|
||||
id: stashed.id,
|
||||
doc: {
|
||||
// ...doc.replace.doc,
|
||||
@@ -439,7 +448,8 @@ export async function stashScene(sceneId, stashId, sessionUser) {
|
||||
|
||||
// return fetchDomainStashes('scene', sceneId, sessionUser);
|
||||
return curateStashed(stashed);
|
||||
} catch (error) {
|
||||
}
|
||||
catch (error) {
|
||||
if (error.routine === '_bt_check_unique') {
|
||||
throw new HttpError(`Scene ${sceneId} is already stashed in '${stash.name}'`, 409);
|
||||
}
|
||||
@@ -475,7 +485,7 @@ export async function unstashScene(sceneId, stashId, sessionUser) {
|
||||
.returning('*');
|
||||
|
||||
await indexApi.callDelete({
|
||||
index: 'scenes_stashed',
|
||||
table: 'scenes_stashed',
|
||||
query: {
|
||||
bool: {
|
||||
must: [
|
||||
@@ -519,7 +529,7 @@ export async function stashMovie(movieId, stashId, sessionUser) {
|
||||
.returning('*');
|
||||
|
||||
await indexApi.replace({
|
||||
index: 'movies_stashed',
|
||||
table: 'movies_stashed',
|
||||
id: stashed.id,
|
||||
doc: {
|
||||
movie_id: movieId,
|
||||
@@ -535,7 +545,8 @@ export async function stashMovie(movieId, stashId, sessionUser) {
|
||||
|
||||
// return fetchDomainStashes('movie', movieId, sessionUser);
|
||||
return curateStashed(stashed);
|
||||
} catch (error) {
|
||||
}
|
||||
catch (error) {
|
||||
if (error.routine === '_bt_check_unique') {
|
||||
throw new HttpError(`Movie ${movieId} is already stashed in '${stash.name}'`, 409);
|
||||
}
|
||||
@@ -571,7 +582,7 @@ export async function unstashMovie(movieId, stashId, sessionUser) {
|
||||
.delete();
|
||||
|
||||
await indexApi.callDelete({
|
||||
index: 'movies_stashed',
|
||||
table: 'movies_stashed',
|
||||
query: {
|
||||
bool: {
|
||||
must: [
|
||||
|
||||
Reference in New Issue
Block a user