Converting expression before storing. Pre-fixed some Bang! channel names with 'Bang!'.

This commit is contained in:
DebaucheryLibrarian
2024-05-29 23:57:38 +02:00
parent 43d85bcd34
commit f956f0e112
4 changed files with 14 additions and 14 deletions

View File

@@ -41,7 +41,9 @@ async function addAlert(alert, sessionUser) {
alert.matches?.length > 0 && bulkInsert('alerts_matches', alert.matches.map((match) => ({
alert_id: alertId,
property: match.property,
expression: match.expression,
expression: /\/.*\//.test(match.expression)
? match.expression.slice(1, -1)
: escapeRegexp(match.expression),
})), false),
alert.stashes?.length > 0 && bulkInsert('alerts_stashes', alert.stashes.map((stashId) => ({
alert_id: alertId,
@@ -115,9 +117,7 @@ async function notify(scenes) {
acc[alertMatch.alert_id].push({
property: alertMatch.property,
expression: /\/.*\//.test(alertMatch.expression)
? new RegExp(alertMatch.expression.slice(1, -1), 'ui')
: new RegExp(escapeRegexp(alertMatch.expression), 'ui'),
expression: new RegExp(alertMatch.expression, 'ui'),
});
return acc;