Browse Source

Hotfix for "Hastic instance name #558":

- alert -> payload
pull/1/head
rozetko 6 years ago
parent
commit
436c2a7cab
  1. 7
      server/src/services/notification_service.ts

7
server/src/services/notification_service.ts

@ -61,10 +61,11 @@ export async function sendWebhook(payload: any) {
payload.instanceName = HASTIC_INSTANCE_NAME; payload.instanceName = HASTIC_INSTANCE_NAME;
let data;
if(HASTIC_WEBHOOK_TYPE === ContentType.JSON) { if(HASTIC_WEBHOOK_TYPE === ContentType.JSON) {
payload = JSON.stringify(alert); data = JSON.stringify(payload);
} else if(HASTIC_WEBHOOK_TYPE === ContentType.URLENCODED) { } else if(HASTIC_WEBHOOK_TYPE === ContentType.URLENCODED) {
payload = querystring.stringify(alert); data = querystring.stringify(payload);
} else { } else {
throw new Error(`Unknown webhook type: ${HASTIC_WEBHOOK_TYPE}`); throw new Error(`Unknown webhook type: ${HASTIC_WEBHOOK_TYPE}`);
} }
@ -73,7 +74,7 @@ export async function sendWebhook(payload: any) {
const options = { const options = {
method: 'POST', method: 'POST',
url: HASTIC_WEBHOOK_URL, url: HASTIC_WEBHOOK_URL,
data: payload, data,
headers: { 'Content-Type': HASTIC_WEBHOOK_TYPE } headers: { 'Content-Type': HASTIC_WEBHOOK_TYPE }
}; };

Loading…
Cancel
Save