Add Filter for webhooks
This commit is contained in:
19
src/index.js
19
src/index.js
@@ -34,9 +34,19 @@ const credentials = {
|
||||
cert: certificate,
|
||||
};
|
||||
|
||||
const callWebhooks = () => {
|
||||
config?.triggerWebhooks?.forEach((webhook) => {
|
||||
axios.get(webhook);
|
||||
const callWebhooks = async (title) => {
|
||||
config?.triggerWebhooks?.forEach(async (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);
|
||||
}
|
||||
|
||||
await callWebhooks(data.title);
|
||||
|
||||
if (data.title.includes("Probealarm")) {
|
||||
sendMessage("[INFO]: Einsatdepesche abgebrochen", messageIDs);
|
||||
return;
|
||||
}
|
||||
|
||||
callWebhooks();
|
||||
|
||||
const filePath = cacheFolder + data.foreign_id + ".pdf";
|
||||
await createPDF({ filePath, ...data });
|
||||
|
||||
Reference in New Issue
Block a user