Added user ID requirement to notify tool to prevent mass-notifying all users.
This commit is contained in:
@@ -616,25 +616,27 @@ export async function notify(sceneIds, options = {}) {
|
|||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
const alerts = rawAlerts.map((alert) => ({
|
const alerts = rawAlerts
|
||||||
id: alert.id,
|
.map((alert) => ({
|
||||||
userId: alert.user_id,
|
id: alert.id,
|
||||||
username: alert.username,
|
userId: alert.user_id,
|
||||||
userEmail: alert.user_email,
|
username: alert.username,
|
||||||
userSettings: alert.user_settings,
|
userEmail: alert.user_email,
|
||||||
notify: alert.notify,
|
userSettings: alert.user_settings,
|
||||||
email: alert.email,
|
notify: alert.notify,
|
||||||
all: alert.all,
|
email: alert.email,
|
||||||
allActors: alert.all_actors,
|
all: alert.all,
|
||||||
allEntities: alert.all_entities,
|
allActors: alert.all_actors,
|
||||||
allTags: alert.all_tags,
|
allEntities: alert.all_entities,
|
||||||
allMatches: alert.all_matches,
|
allTags: alert.all_tags,
|
||||||
actorIds: alertActorIdsByAlertId[alert.id] || [],
|
allMatches: alert.all_matches,
|
||||||
tagIds: alertTagIdsByAlertId[alert.id] || [],
|
actorIds: alertActorIdsByAlertId[alert.id] || [],
|
||||||
entityIds: alertEntityIdsByAlertId[alert.id] || [],
|
tagIds: alertTagIdsByAlertId[alert.id] || [],
|
||||||
matches: alertsMatchesByAlertId[alert.id] || [],
|
entityIds: alertEntityIdsByAlertId[alert.id] || [],
|
||||||
stashIds: alertsStashesByAlertId[alert.id] || [],
|
matches: alertsMatchesByAlertId[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)
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user