Added stash GraphQL mutations. Added movies to GraphQL queries. Moved key management to profile page, only for approved users.

This commit is contained in:
2025-03-31 06:14:56 +02:00
parent 09bba4fe1e
commit 1025285796
14 changed files with 721 additions and 235 deletions

View File

@@ -9,6 +9,8 @@ import {
reviewSceneRevision,
} from '../scenes.js';
import { fetchStashByUsernameAndSlug } from '../stashes.js';
import { parseActorIdentifier } from '../query.js';
import { getIdsBySlug } from '../cache.js';
import slugify from '../../utils/slugify.js';
@@ -87,6 +89,8 @@ export const scenesSchema = `
entities: [String!]
actorIds: [String!]
tags: [String!]
movieId: Int
stash: String
limit: Int! = 30
page: Int! = 1
): ReleasesResult
@@ -152,9 +156,33 @@ export const scenesSchema = `
}
`;
function getScope(query) {
if (query.scope) {
return query.scope;
}
if (query.query) {
return 'results';
}
if (query.stash) {
return 'stashed';
}
return 'latest';
}
export async function fetchScenesGraphql(query, req) {
const mainEntity = query.entities?.find((entity) => entity.charAt(0) !== '!');
const stash = query.stash && req.user
? await fetchStashByUsernameAndSlug(req.user.id, query.stash, req.user)
: null;
if (query.stash && !stash) {
throw new HttpError(`Could not find stash '${query.stash}'`, 404);
}
const {
tagIds,
notTagIds,
@@ -183,9 +211,9 @@ export async function fetchScenesGraphql(query, req) {
notEntityIds,
actorIds: query.actorIds?.filter((actorId) => actorId.charAt(0) !== '!').map((actorId) => Number(actorId)),
notActorIds: query.actorIds?.filter((actorId) => actorId.charAt(0) === '!').map((actorId) => Number(actorId.slice(1))),
scope: query.query && !query.scope
? 'results'
: query.scope,
movieId: query.movieId,
stashId: stash?.id,
scope: getScope(query),
isShowcased: null,
}, {
page: query.page || 1,