Added user ID requirement to notify tool to prevent mass-notifying all users.

This commit is contained in:
2026-07-21 04:41:29 +02:00
parent 49ef28a5bf
commit 5b17eb15a2
2 changed files with 34 additions and 21 deletions

View File

@@ -616,7 +616,8 @@ export async function notify(sceneIds, options = {}) {
return acc; return acc;
}, {}); }, {});
const alerts = rawAlerts.map((alert) => ({ const alerts = rawAlerts
.map((alert) => ({
id: alert.id, id: alert.id,
userId: alert.user_id, userId: alert.user_id,
username: alert.username, username: alert.username,
@@ -634,7 +635,8 @@ export async function notify(sceneIds, options = {}) {
entityIds: alertEntityIdsByAlertId[alert.id] || [], entityIds: alertEntityIdsByAlertId[alert.id] || [],
matches: alertsMatchesByAlertId[alert.id] || [], matches: alertsMatchesByAlertId[alert.id] || [],
stashIds: alertsStashesByAlertId[alert.id] || [], stashIds: alertsStashesByAlertId[alert.id] || [],
})); }))
.filter((alert) => options.spoofUserIds ? options.spoofUserIds.includes(alert.userId) : true);
const curatedScenes = scenes const curatedScenes = scenes
.filter((scene) => scene.isNew || options.spoofNew) .filter((scene) => scene.isNew || options.spoofNew)

View File

@@ -9,14 +9,25 @@ const { argv } = yargs(process.argv.slice(2))
.option('scenes', { .option('scenes', {
type: 'array', type: 'array',
alias: ['scene-ids'], alias: ['scene-ids'],
})
.option('user-ids', {
type: 'array',
alias: ['users', 'user'],
}); });
async function triggerNotify() { async function triggerNotify() {
if (!argv.scenes.length) { if (!argv.scenes?.length) {
throw new Error('Must specify at least one scene ID'); 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 knex.destroy();
await redis.quit(); await redis.quit();