From 5b17eb15a253a0c99a34e75790f3279b29057566 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Tue, 21 Jul 2026 04:41:29 +0200 Subject: [PATCH] Added user ID requirement to notify tool to prevent mass-notifying all users. --- src/alerts.js | 40 +++++++++++++++++++++------------------- tools/notify.js | 15 +++++++++++++-- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/src/alerts.js b/src/alerts.js index 2d624ec..721eec5 100755 --- a/src/alerts.js +++ b/src/alerts.js @@ -616,25 +616,27 @@ export async function notify(sceneIds, options = {}) { return acc; }, {}); - const alerts = rawAlerts.map((alert) => ({ - id: alert.id, - userId: alert.user_id, - username: alert.username, - userEmail: alert.user_email, - userSettings: alert.user_settings, - notify: alert.notify, - email: alert.email, - all: alert.all, - allActors: alert.all_actors, - allEntities: alert.all_entities, - allTags: alert.all_tags, - allMatches: alert.all_matches, - actorIds: alertActorIdsByAlertId[alert.id] || [], - tagIds: alertTagIdsByAlertId[alert.id] || [], - entityIds: alertEntityIdsByAlertId[alert.id] || [], - matches: alertsMatchesByAlertId[alert.id] || [], - stashIds: alertsStashesByAlertId[alert.id] || [], - })); + const alerts = rawAlerts + .map((alert) => ({ + id: alert.id, + userId: alert.user_id, + username: alert.username, + userEmail: alert.user_email, + userSettings: alert.user_settings, + notify: alert.notify, + email: alert.email, + all: alert.all, + allActors: alert.all_actors, + allEntities: alert.all_entities, + allTags: alert.all_tags, + allMatches: alert.all_matches, + actorIds: alertActorIdsByAlertId[alert.id] || [], + tagIds: alertTagIdsByAlertId[alert.id] || [], + entityIds: alertEntityIdsByAlertId[alert.id] || [], + matches: alertsMatchesByAlertId[alert.id] || [], + stashIds: alertsStashesByAlertId[alert.id] || [], + })) + .filter((alert) => options.spoofUserIds ? options.spoofUserIds.includes(alert.userId) : true); const curatedScenes = scenes .filter((scene) => scene.isNew || options.spoofNew) diff --git a/tools/notify.js b/tools/notify.js index 91988da..60bb1f0 100644 --- a/tools/notify.js +++ b/tools/notify.js @@ -9,14 +9,25 @@ const { argv } = yargs(process.argv.slice(2)) .option('scenes', { type: 'array', alias: ['scene-ids'], + }) + .option('user-ids', { + type: 'array', + alias: ['users', 'user'], }); async function triggerNotify() { - if (!argv.scenes.length) { + if (!argv.scenes?.length) { throw new Error('Must specify at least one scene ID'); } - await notify(argv.scenes, { spoofNew: true }); + if (!argv.userIds?.length) { + throw new Error('Must specify at least one user ID'); + } + + await notify(argv.scenes, { + spoofNew: true, + spoofUserIds: argv.userIds, + }); await knex.destroy(); await redis.quit();