remove redundant method
This commit is contained in:
1 parent
be8580ee99
commit
412a3b7cc9
5 files changed
+10
-15
No files matched your search
@@ -5,7 +5,7 @@ import type { MonitorActionDecision } from "@/service/infrastructure/SuperSimple
|
|||||||
import type { Notification, Monitor, MonitorStatusResponse } from "@/types/index.js";
|
import type { Notification, Monitor, MonitorStatusResponse } from "@/types/index.js";
|
||||||
import {
|
import {
|
||||||
buildHardwareAlerts,
|
buildHardwareAlerts,
|
||||||
buildHardwareWebhookBody,
|
buildHardwareNotificationMessage,
|
||||||
buildWebhookBody,
|
buildWebhookBody,
|
||||||
getTestMessage,
|
getTestMessage,
|
||||||
} from "@/service/infrastructure/notificationProviders/utils.js";
|
} from "@/service/infrastructure/notificationProviders/utils.js";
|
||||||
@@ -28,7 +28,7 @@ export class MatrixProvider implements INotificationProvider {
|
|||||||
}
|
}
|
||||||
// For threshold breaches, use hardware alert format
|
// For threshold breaches, use hardware alert format
|
||||||
const { alertsToSend } = buildHardwareAlerts("HOST_PLACEHOLDER", monitor, monitorStatusResponse);
|
const { alertsToSend } = buildHardwareAlerts("HOST_PLACEHOLDER", monitor, monitorStatusResponse);
|
||||||
const body = buildHardwareWebhookBody(clientHost, alertsToSend, monitor);
|
const body = buildHardwareNotificationMessage(clientHost, alertsToSend, monitor);
|
||||||
return body;
|
return body;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type { MonitorActionDecision } from "@/service/infrastructure/SuperSimple
|
|||||||
import { INotificationProvider } from "@/service/index.js";
|
import { INotificationProvider } from "@/service/index.js";
|
||||||
import {
|
import {
|
||||||
buildHardwareAlerts,
|
buildHardwareAlerts,
|
||||||
buildHardwareWebhookBody,
|
buildHardwareNotificationMessage,
|
||||||
buildWebhookBody,
|
buildWebhookBody,
|
||||||
getTestMessage,
|
getTestMessage,
|
||||||
} from "@/service/infrastructure/notificationProviders/utils.js";
|
} from "@/service/infrastructure/notificationProviders/utils.js";
|
||||||
@@ -28,7 +28,7 @@ export class PagerDutyProvider implements INotificationProvider {
|
|||||||
}
|
}
|
||||||
// For threshold breaches, use hardware alert format
|
// For threshold breaches, use hardware alert format
|
||||||
const { alertsToSend } = buildHardwareAlerts("HOST_PLACEHOLDER", monitor, monitorStatusResponse);
|
const { alertsToSend } = buildHardwareAlerts("HOST_PLACEHOLDER", monitor, monitorStatusResponse);
|
||||||
const body = buildHardwareWebhookBody(clientHost, alertsToSend, monitor);
|
const body = buildHardwareNotificationMessage(clientHost, alertsToSend, monitor);
|
||||||
return body;
|
return body;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { INotificationProvider } from "@/service/index.js";
|
|||||||
import type { MonitorActionDecision } from "@/service/infrastructure/SuperSimpleQueue/SuperSimpleQueueHelper.js";
|
import type { MonitorActionDecision } from "@/service/infrastructure/SuperSimpleQueue/SuperSimpleQueueHelper.js";
|
||||||
import {
|
import {
|
||||||
buildHardwareAlerts,
|
buildHardwareAlerts,
|
||||||
buildHardwareWebhookBody,
|
buildHardwareNotificationMessage,
|
||||||
buildWebhookBody,
|
buildWebhookBody,
|
||||||
getTestMessage,
|
getTestMessage,
|
||||||
} from "@/service/infrastructure/notificationProviders/utils.js";
|
} from "@/service/infrastructure/notificationProviders/utils.js";
|
||||||
@@ -28,7 +28,7 @@ export class SlackProvider implements INotificationProvider {
|
|||||||
}
|
}
|
||||||
// For threshold breaches, use hardware alert format
|
// For threshold breaches, use hardware alert format
|
||||||
const { alertsToSend } = buildHardwareAlerts("HOST_PLACEHOLDER", monitor, monitorStatusResponse);
|
const { alertsToSend } = buildHardwareAlerts("HOST_PLACEHOLDER", monitor, monitorStatusResponse);
|
||||||
const body = buildHardwareWebhookBody(clientHost, alertsToSend, monitor);
|
const body = buildHardwareNotificationMessage(clientHost, alertsToSend, monitor);
|
||||||
return body;
|
return body;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -116,16 +116,11 @@ export const buildHardwareAlerts = (
|
|||||||
return { alertsToSend, discordPayload };
|
return { alertsToSend, discordPayload };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const buildHardwareNotificationMessage = (clientHost: string, alerts: any, monitor: Monitor) => {
|
export const buildHardwareNotificationMessage = (clientHost: string, alerts: string[], monitor: Monitor): string => {
|
||||||
const alertsHeader = [`Monitor: ${monitor.name}`, `URL: ${monitor.url}`];
|
const alertsHeader = [`Monitor: ${monitor.name}`, `URL: ${monitor.url}`];
|
||||||
const alertFooter = [`Go to incident: ${clientHost}/infrastructure/${monitor.id}`];
|
const alertFooter = [`Go to incident: ${clientHost}/infrastructure/${monitor.id}`];
|
||||||
const alertText = alerts.length > 0 ? [...alertsHeader, ...alerts, ...alertFooter] : [];
|
const alertText = alerts.length > 0 ? [...alertsHeader, ...alerts, ...alertFooter] : [];
|
||||||
return alertText.map((alert) => alert).join("\n");
|
return alertText.join("\n");
|
||||||
};
|
|
||||||
|
|
||||||
export const buildHardwareWebhookBody = (clientHost: string, alerts: string[], monitor: Monitor): string => {
|
|
||||||
const content = buildHardwareNotificationMessage(clientHost, alerts, monitor);
|
|
||||||
return content;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const buildWebhookBody = (monitor: Monitor, monitorStatusResponse: MonitorStatusResponse) => {
|
export const buildWebhookBody = (monitor: Monitor, monitorStatusResponse: MonitorStatusResponse) => {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { INotificationProvider } from "@/service/index.js";
|
|||||||
import type { MonitorActionDecision } from "@/service/infrastructure/SuperSimpleQueue/SuperSimpleQueueHelper.js";
|
import type { MonitorActionDecision } from "@/service/infrastructure/SuperSimpleQueue/SuperSimpleQueueHelper.js";
|
||||||
import {
|
import {
|
||||||
buildHardwareAlerts,
|
buildHardwareAlerts,
|
||||||
buildHardwareWebhookBody,
|
buildHardwareNotificationMessage,
|
||||||
buildWebhookBody,
|
buildWebhookBody,
|
||||||
getTestMessage,
|
getTestMessage,
|
||||||
} from "@/service/infrastructure/notificationProviders/utils.js";
|
} from "@/service/infrastructure/notificationProviders/utils.js";
|
||||||
@@ -28,7 +28,7 @@ export class WebhookProvider implements INotificationProvider {
|
|||||||
}
|
}
|
||||||
// For threshold breaches, use hardware alert format
|
// For threshold breaches, use hardware alert format
|
||||||
const { alertsToSend } = buildHardwareAlerts("HOST_PLACEHOLDER", monitor, monitorStatusResponse);
|
const { alertsToSend } = buildHardwareAlerts("HOST_PLACEHOLDER", monitor, monitorStatusResponse);
|
||||||
const body = buildHardwareWebhookBody(clientHost, alertsToSend, monitor);
|
const body = buildHardwareNotificationMessage(clientHost, alertsToSend, monitor);
|
||||||
return body;
|
return body;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user