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,
|
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 });
|
||||||
|
|||||||
Reference in New Issue
Block a user