Add Filter for webhooks

This commit is contained in:
Stefan080106
2023-11-18 14:14:34 +01:00
parent a3461dee61
commit 2411615ecd

View File

@@ -34,9 +34,19 @@ const credentials = {
cert: certificate, cert: certificate,
}; };
const callWebhooks = () => { const callWebhooks = async (title) => {
config?.triggerWebhooks?.forEach((webhook) => { config?.triggerWebhooks?.forEach(async (webhook) => {
axios.get(webhook); if (webhook?.filter?.length > 0) {
let filterPass = true;
webhook?.filter?.forEach((filter) => {
if (title.includes(filter)) filterPass = false;
})
if (filterPass) await axios.get(webhook.url);
} else {
await axios.get(webhook.url);
}
}); });
} }
@@ -153,12 +163,13 @@ async function main(data) {
sendMessage("[INFO]: Einsatdepesche wird Gedruckt - " + data.title, messageIDs); sendMessage("[INFO]: Einsatdepesche wird Gedruckt - " + data.title, messageIDs);
} }
await callWebhooks(data.title);
if (data.title.includes("Probealarm")) { if (data.title.includes("Probealarm")) {
sendMessage("[INFO]: Einsatdepesche abgebrochen", messageIDs); sendMessage("[INFO]: Einsatdepesche abgebrochen", messageIDs);
return; return;
} }
callWebhooks();
const filePath = cacheFolder + data.foreign_id + ".pdf"; const filePath = cacheFolder + data.foreign_id + ".pdf";
await createPDF({ filePath, ...data }); await createPDF({ filePath, ...data });