Compare commits

...

2 Commits

Author SHA1 Message Date
DebaucheryLibrarian 43d85bcd34 1.237.12 2024-05-20 06:29:48 +02:00
DebaucheryLibrarian 0f05abcd27 Implemented alert field AND/OR logic. 2024-05-20 06:29:44 +02:00
4 changed files with 24 additions and 10 deletions

View File

@ -16,6 +16,16 @@ exports.up = async (knex) => {
.notNullable()
.defaultTo(true);
});
await knex.raw(`
UPDATE alerts
SET
all_actors = false,
all_entities = false,
all_tags = false,
all_matches= false
WHERE alerts.all = false;
`);
};
exports.down = async (knex) => {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "traxxx",
"version": "1.237.11",
"version": "1.237.12",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "traxxx",
"version": "1.237.11",
"version": "1.237.12",
"license": "ISC",
"dependencies": {
"@aws-sdk/client-s3": "^3.458.0",

View File

@ -1,6 +1,6 @@
{
"name": "traxxx",
"version": "1.237.11",
"version": "1.237.12",
"description": "All the latest porn releases in one place",
"main": "src/app.js",
"scripts": {

View File

@ -129,6 +129,10 @@ async function notify(scenes) {
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,
actors: alertsActorsByAlertId[alert.id] || [],
tags: alertsTagsByAlertId[alert.id] || [],
entities: alertsEntitiesByAlertId[alert.id] || [],
@ -149,11 +153,11 @@ async function notify(scenes) {
const triggers = alerts.flatMap((alert) => {
const alertScenes = curatedScenes.filter((scene) => {
if (alert.all) {
if (alert.actors.length > 0 && !alert.actors.every((actorId) => scene.actorIds.includes(actorId))) {
if (alert.actors.length > 0 && !alert.actors[alert.allActors ? 'every' : 'some']((actorId) => scene.actorIds.includes(actorId))) {
return false;
}
if (alert.tags.length > 0 && !alert.tags.every((tagId) => scene.tagIds.includes(tagId))) {
if (alert.tags.length > 0 && !alert.tags[alert.allTags ? 'every' : 'some']((tagId) => scene.tagIds.includes(tagId))) {
return false;
}
@ -162,27 +166,27 @@ async function notify(scenes) {
return false;
}
if (alert.matches.length > 0 && !alert.matches.every((match) => match.expression.test(scene[match.property]))) {
if (alert.matches.length > 0 && !alert.matches[alert.allMatches ? 'every' : 'some']((match) => match.expression.test(scene[match.property]))) {
return false;
}
return true;
}
if (alert.actors.some((actorId) => scene.actorIds.includes(actorId))) {
if (alert.matches.length > 0 && alert.actors[alert.allActors ? 'every' : 'some']((actorId) => scene.actorIds.includes(actorId))) {
return true;
}
if (alert.tags.some((tagId) => scene.tagIds.includes(tagId))) {
if (alert.tags.length > 0 && alert.tags[alert.allTags ? 'every' : 'some']((tagId) => scene.tagIds.includes(tagId))) {
return true;
}
// multiple entities can only be matched in OR mode
if (alert.entities.some((alertEntityId) => alertEntityId === scene.entityId || alertEntityId === scene.parentEntityId)) {
if (alert.entities.length > 0 && alert.entities.some((alertEntityId) => alertEntityId === scene.entityId || alertEntityId === scene.parentEntityId)) {
return true;
}
if (alert.matches.some((match) => match.expression.test(scene[match.property]))) {
if (alert.matches.length > 0 && alert.matches[alert.allMatches ? 'every' : 'some']((match) => match.expression.test(scene[match.property]))) {
return true;
}