From 981205efaa0f6927a933f1bc6a26cacf554b9d6f Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Sat, 18 Jul 2026 01:02:03 +0200 Subject: [PATCH] Enabled e-mail action in alert dialog and alerts overview action indicators. --- components/alerts/alerts.vue | 26 ++++++++++++-------------- components/alerts/create.vue | 13 +++++++++---- src/alerts.js | 4 ++-- src/users.js | 12 ++++++++---- src/web/actors.js | 11 ++++++----- src/web/alerts.js | 7 ++++--- src/web/auth.js | 4 ++-- src/web/entities.js | 3 ++- src/web/error.js | 10 ++++++---- src/web/main.js | 1 + src/web/movies.js | 2 +- src/web/scenes.js | 4 ++-- src/web/stashes.js | 19 ++++++++++--------- src/web/tags.js | 4 +++- src/web/users.js | 2 +- 15 files changed, 69 insertions(+), 53 deletions(-) diff --git a/components/alerts/alerts.vue b/components/alerts/alerts.vue index 4c8a6fe..43ed05c 100644 --- a/components/alerts/alerts.vue +++ b/components/alerts/alerts.vue @@ -320,16 +320,22 @@ function toggleFilterCombined() {
+ + - -
diff --git a/components/alerts/create.vue b/components/alerts/create.vue index b725e23..3e7b9ef 100644 --- a/components/alerts/create.vue +++ b/components/alerts/create.vue @@ -24,7 +24,11 @@ const props = defineProps({ const emit = defineEmits(['alert', 'close']); -const { assets } = inject('pageContext'); +const { + assets, + user, + env, +} = inject('pageContext'); const actors = ref(props.presetActors); const actorResults = ref([]); @@ -462,8 +466,10 @@ function selectStash(selectedStash) { /> -
    diff --git a/src/alerts.js b/src/alerts.js index df3bf72..d29fd36 100755 --- a/src/alerts.js +++ b/src/alerts.js @@ -572,10 +572,10 @@ export async function notify(sceneIds) { slug: scene.slug, date: scene.date, description: scene.description, - actors: (actorsByReleaseId[scene.id] || []).filter(Boolean).map((actor) => ({ id: actor.actor_id, name: actor.actor_name, slug: actor.slug })), + actors: (actorsByReleaseId[scene.id] || []).filter((actor) => !!actor.actor_name).map((actor) => ({ id: actor.actor_id, name: actor.actor_name, slug: actor.slug })), actorIds: (actorsByReleaseId[scene.id] || []).map((actor) => actor.actor_id), tagIds: (tagsByReleaseId[scene.id] || []).map((tag) => tag.id), - tags: (tagsByReleaseId[scene.id] || []).filter(Boolean).map((tag) => ({ slug: tag.tag_slug, name: tag.tag_name })), + tags: (tagsByReleaseId[scene.id] || []).filter((tag) => !!tag.tag_name).map((tag) => ({ slug: tag.tag_slug, name: tag.tag_name })), entityId: scene.channel?.id || scene.network?.id || null, parentEntityId: scene.network?.id, posterUrl: getImagePath(scene.poster), diff --git a/src/users.js b/src/users.js index 1b094da..57a6009 100755 --- a/src/users.js +++ b/src/users.js @@ -14,7 +14,7 @@ function curateTemplate(template) { }; } -export function curateUser(user, _assets = {}) { +export function curateUser(user, _assets = {}, reqUser) { if (!user) { return null; } @@ -24,13 +24,17 @@ export function curateUser(user, _assets = {}) { const curatedUser = { id: user.id, username: user.username, - email: user.email, isEmailVerified: user.email_verified, isIdentityVerified: user.identity_verified, avatar: `/media/avatars/${user.id}_${user.username}.png`, role: user.role, abilities: [...user.role_abilities || [], ...user.abilities || []], createdAt: user.created_at, + ...(reqUser?.id === user.id + ? { + email: user.email, + } + : null), }; return curatedUser; @@ -50,7 +54,7 @@ function whereUser(builder, userId, options = {}) { builder.where('users.id', Number(userId)); } -export async function fetchUser(userId, options = {}, _reqUser) { +export async function fetchUser(userId, options = {}, reqUser) { const user = await knex('users') .select(knex.raw('users.*, users_roles.abilities as role_abilities')) .modify((builder) => whereUser(builder, userId, options)) @@ -68,7 +72,7 @@ export async function fetchUser(userId, options = {}, _reqUser) { } // return curateUser(user, { stashes, templates }); - return curateUser(user, {}); + return curateUser(user, {}, reqUser); } export async function fetchUserTemplates(reqUser) { diff --git a/src/web/actors.js b/src/web/actors.js index d5badf8..972689b 100644 --- a/src/web/actors.js +++ b/src/web/actors.js @@ -1,3 +1,4 @@ +import { stringify } from '@brillout/json-serializer/stringify'; import { Router } from 'express'; import omit from 'object.omit'; @@ -44,12 +45,12 @@ export async function fetchActorsApi(req, res) { order: req.query.order?.split('.') || ['likes', 'desc'], }, req.user); - res.send({ + res.send(stringify({ actors, countries, limit, total, - }); + })); } export const actorsSchema = ` @@ -188,7 +189,7 @@ export async function fetchActorsByIdGraphql(query, _req, _info) { export async function createActorApi(req, res) { const actor = await createActor(req.body.actor, omit(req.body, ['actor']), req.user); - res.send({ actor }); + res.send(stringify({ actor })); } export async function mergeActorsApi(req, res) { @@ -199,13 +200,13 @@ export async function mergeActorsApi(req, res) { req.user, ); - res.send(result); + res.send(stringify(result)); } async function fetchActorRevisionsApi(req, res) { const revisions = await fetchActorRevisions(Number(req.params.revisionId) || null, req.query, req.user); - res.send(revisions); + res.send(stringify(revisions)); } async function createActorRevisionApi(req, res) { diff --git a/src/web/alerts.js b/src/web/alerts.js index 4a59508..7c86702 100755 --- a/src/web/alerts.js +++ b/src/web/alerts.js @@ -1,3 +1,4 @@ +import { stringify } from '@brillout/json-serializer/stringify'; import { Router } from 'express'; import { @@ -146,7 +147,7 @@ export const alertsSchema = ` export async function fetchAlertsApi(req, res) { const alerts = await fetchAlerts(req.user); - res.send(alerts); + res.send(stringify(alerts)); } export async function fetchAlertsGraphql(query, req) { @@ -158,7 +159,7 @@ export async function fetchAlertsGraphql(query, req) { export async function createAlertApi(req, res) { const alert = await createAlert(req.body, req.user); - res.send(alert); + res.send(stringify(alert)); } export async function createAlertGraphql(query, req) { @@ -184,7 +185,7 @@ export async function fetchNotificationsApi(req, res) { limit: req.query.limit || 10, }); - res.send(notifications); + res.send(stringify(notifications)); } export async function fetchNotificationsGraphql(query, req) { diff --git a/src/web/auth.js b/src/web/auth.js index 0a06a6b..893b2be 100755 --- a/src/web/auth.js +++ b/src/web/auth.js @@ -67,7 +67,7 @@ export async function loginApi(req, res) { const user = await login(req.body, req.userIp); req.session.user = user; - res.send(user); + res.send(stringify(user)); } export async function logoutApi(req, res) { @@ -84,7 +84,7 @@ export async function signupApi(req, res) { const user = await signup(req.body, req.userIp); req.session.user = user; - res.send(user); + res.send(stringify(user)); } export async function fetchUserKeysApi(req, res) { diff --git a/src/web/entities.js b/src/web/entities.js index bda9dae..a02baa9 100644 --- a/src/web/entities.js +++ b/src/web/entities.js @@ -1,3 +1,4 @@ +import { stringify } from '@brillout/json-serializer/stringify'; import { parseResolveInfo } from 'graphql-parse-resolve-info'; import { getIdsBySlug } from '../cache.js'; @@ -10,7 +11,7 @@ import { export async function fetchEntitiesApi(req, res) { const entities = await fetchEntities(req.query); - res.send(entities); + res.send(stringify(entities)); } export const entitiesSchema = ` diff --git a/src/web/error.js b/src/web/error.js index 527bf05..f78ed23 100755 --- a/src/web/error.js +++ b/src/web/error.js @@ -1,3 +1,5 @@ +import { stringify } from '@brillout/json-serializer/stringify'; + import argv from '../argv.js'; import initLogger from '../logger.js'; @@ -11,16 +13,16 @@ export default function errorHandler(error, req, res, _next) { } if (error.httpCode) { - res.status(error.httpCode).send({ + res.status(error.httpCode).send(stringify({ statusCode: error.httpCode, statusMessage: error.message, - }); + })); return; } - res.status(500).send({ + res.status(500).send(stringify({ statusCode: 500, statusMessage: 'Oops... our server messed up. We will be investigating this incident, our apologies for the inconvenience.', - }); + })); } diff --git a/src/web/main.js b/src/web/main.js index 0bac31d..1b19663 100644 --- a/src/web/main.js +++ b/src/web/main.js @@ -52,6 +52,7 @@ export default async function mainHandler(req, res, next) { psa: config.psa, links: config.links, socials, + emailEnabled: config.email.enabled, captcha: { enabled: config.auth.captcha.enabled, siteKey: config.auth.captcha.siteKey, diff --git a/src/web/movies.js b/src/web/movies.js index 2c0b2ab..3f487f7 100644 --- a/src/web/movies.js +++ b/src/web/movies.js @@ -53,7 +53,7 @@ export async function fetchMovieApi(req, res) { throw new HttpError(`No movie with ID ${req.params.movieId} found`, 404); } - res.send(movie); + res.send(stringify(movie)); } export const moviesSchema = ` diff --git a/src/web/scenes.js b/src/web/scenes.js index e465f69..6c0609e 100644 --- a/src/web/scenes.js +++ b/src/web/scenes.js @@ -261,7 +261,7 @@ async function fetchSceneApi(req, res) { throw new HttpError(`No scene with ID ${req.params.sceneId} found`, 404); } - res.send(scene); + res.send(stringify(scene)); } export async function fetchScenesByIdGraphql(query, req) { @@ -281,7 +281,7 @@ export async function fetchScenesByIdGraphql(query, req) { async function fetchSceneRevisionsApi(req, res) { const revisions = await fetchSceneRevisions(Number(req.params.revisionId) || null, req.query, req.user); - res.send(revisions); + res.send(stringify(revisions)); } async function createSceneRevisionApi(req, res) { diff --git a/src/web/stashes.js b/src/web/stashes.js index 2edb859..66fdfcf 100755 --- a/src/web/stashes.js +++ b/src/web/stashes.js @@ -1,3 +1,4 @@ +import { stringify } from '@brillout/json-serializer/stringify'; import { Router } from 'express'; import { @@ -100,7 +101,7 @@ export const stashesSchema = ` export async function fetchUserStashesApi(req, res) { const stashes = await fetchUserStashes(req.user.id, req.user); - res.send(stashes); + res.send(stringify(stashes)); } export async function fetchUserStashesGraphql(query, req) { @@ -118,7 +119,7 @@ export async function fetchStashGraphql(query, req) { export async function createStashApi(req, res) { const stash = await createStash(req.body, req.user); - res.send(stash); + res.send(stringify(stash)); } export async function createStashGraphql(query, req) { @@ -130,7 +131,7 @@ export async function createStashGraphql(query, req) { export async function updateStashApi(req, res) { const stash = await updateStash(Number(req.params.stashId), req.body, req.user); - res.send(stash); + res.send(stringify(stash)); } export async function updateStashGraphql(query, req) { @@ -154,7 +155,7 @@ export async function removeStashGraphql(query, req) { export async function stashActorApi(req, res) { const stashed = await stashActor(req.body.actorId, Number(req.params.stashId), req.user); - res.send(stashed); + res.send(stringify(stashed)); } export async function stashActorGraphql(query, req) { @@ -166,7 +167,7 @@ export async function stashActorGraphql(query, req) { export async function unstashActorApi(req, res) { const unstashed = await unstashActor(Number(req.params.actorId), Number(req.params.stashId), req.user); - res.send(unstashed); + res.send(stringify(unstashed)); } export async function unstashActorGraphql(query, req) { @@ -178,7 +179,7 @@ export async function unstashActorGraphql(query, req) { export async function stashSceneApi(req, res) { const stashed = await stashScene(req.body.sceneId, Number(req.params.stashId), req.user); - res.send(stashed); + res.send(stringify(stashed)); } export async function stashSceneGraphql(query, req) { @@ -190,7 +191,7 @@ export async function stashSceneGraphql(query, req) { export async function unstashSceneApi(req, res) { const unstashed = await unstashScene(Number(req.params.sceneId), Number(req.params.stashId), req.user); - res.send(unstashed); + res.send(stringify(unstashed)); } export async function unstashSceneGraphql(query, req) { @@ -202,7 +203,7 @@ export async function unstashSceneGraphql(query, req) { export async function stashMovieApi(req, res) { const stashed = await stashMovie(req.body.movieId, Number(req.params.stashId), req.user); - res.send(stashed); + res.send(stringify(stashed)); } export async function stashMovieGraphql(query, req) { @@ -214,7 +215,7 @@ export async function stashMovieGraphql(query, req) { export async function unstashMovieApi(req, res) { const unstashed = await unstashMovie(Number(req.params.movieId), Number(req.params.stashId), req.user); - res.send(unstashed); + res.send(stringify(unstashed)); } export async function unstashMovieGraphql(query, req) { diff --git a/src/web/tags.js b/src/web/tags.js index 5a452f5..5982bfb 100644 --- a/src/web/tags.js +++ b/src/web/tags.js @@ -1,3 +1,5 @@ +import { stringify } from '@brillout/json-serializer/stringify'; + import { fetchTags } from '../tags.js'; export async function fetchTagsApi(req, res) { @@ -7,5 +9,5 @@ export async function fetchTagsApi(req, res) { restriction: req.restriction, }); - res.send(tags); + res.send(stringify(tags)); } diff --git a/src/web/users.js b/src/web/users.js index 1820224..e75a37d 100644 --- a/src/web/users.js +++ b/src/web/users.js @@ -18,7 +18,7 @@ async function fetchUserApi(req, res) { async function fetchUserTemplatesApi(req, res) { const templates = await fetchUserTemplates(req.user); - res.send(templates); + res.send(stringify(templates)); } async function createTemplateApi(req, res) {