mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-18 07:28:31 -05:00
remove redundant method
This commit is contained in:
@@ -5,7 +5,7 @@ import type { MonitorActionDecision } from "@/service/infrastructure/SuperSimple
|
||||
import type { Notification, Monitor, MonitorStatusResponse } from "@/types/index.js";
|
||||
import {
|
||||
buildHardwareAlerts,
|
||||
buildHardwareWebhookBody,
|
||||
buildHardwareNotificationMessage,
|
||||
buildWebhookBody,
|
||||
getTestMessage,
|
||||
} from "@/service/infrastructure/notificationProviders/utils.js";
|
||||
@@ -28,7 +28,7 @@ export class MatrixProvider implements INotificationProvider {
|
||||
}
|
||||
// For threshold breaches, use hardware alert format
|
||||
const { alertsToSend } = buildHardwareAlerts("HOST_PLACEHOLDER", monitor, monitorStatusResponse);
|
||||
const body = buildHardwareWebhookBody(clientHost, alertsToSend, monitor);
|
||||
const body = buildHardwareNotificationMessage(clientHost, alertsToSend, monitor);
|
||||
return body;
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { MonitorActionDecision } from "@/service/infrastructure/SuperSimple
|
||||
import { INotificationProvider } from "@/service/index.js";
|
||||
import {
|
||||
buildHardwareAlerts,
|
||||
buildHardwareWebhookBody,
|
||||
buildHardwareNotificationMessage,
|
||||
buildWebhookBody,
|
||||
getTestMessage,
|
||||
} from "@/service/infrastructure/notificationProviders/utils.js";
|
||||
@@ -28,7 +28,7 @@ export class PagerDutyProvider implements INotificationProvider {
|
||||
}
|
||||
// For threshold breaches, use hardware alert format
|
||||
const { alertsToSend } = buildHardwareAlerts("HOST_PLACEHOLDER", monitor, monitorStatusResponse);
|
||||
const body = buildHardwareWebhookBody(clientHost, alertsToSend, monitor);
|
||||
const body = buildHardwareNotificationMessage(clientHost, alertsToSend, monitor);
|
||||
return body;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { INotificationProvider } from "@/service/index.js";
|
||||
import type { MonitorActionDecision } from "@/service/infrastructure/SuperSimpleQueue/SuperSimpleQueueHelper.js";
|
||||
import {
|
||||
buildHardwareAlerts,
|
||||
buildHardwareWebhookBody,
|
||||
buildHardwareNotificationMessage,
|
||||
buildWebhookBody,
|
||||
getTestMessage,
|
||||
} from "@/service/infrastructure/notificationProviders/utils.js";
|
||||
@@ -28,7 +28,7 @@ export class SlackProvider implements INotificationProvider {
|
||||
}
|
||||
// For threshold breaches, use hardware alert format
|
||||
const { alertsToSend } = buildHardwareAlerts("HOST_PLACEHOLDER", monitor, monitorStatusResponse);
|
||||
const body = buildHardwareWebhookBody(clientHost, alertsToSend, monitor);
|
||||
const body = buildHardwareNotificationMessage(clientHost, alertsToSend, monitor);
|
||||
return body;
|
||||
};
|
||||
|
||||
|
||||
@@ -116,16 +116,11 @@ export const buildHardwareAlerts = (
|
||||
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 alertFooter = [`Go to incident: ${clientHost}/infrastructure/${monitor.id}`];
|
||||
const alertText = alerts.length > 0 ? [...alertsHeader, ...alerts, ...alertFooter] : [];
|
||||
return alertText.map((alert) => alert).join("\n");
|
||||
};
|
||||
|
||||
export const buildHardwareWebhookBody = (clientHost: string, alerts: string[], monitor: Monitor): string => {
|
||||
const content = buildHardwareNotificationMessage(clientHost, alerts, monitor);
|
||||
return content;
|
||||
return alertText.join("\n");
|
||||
};
|
||||
|
||||
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 {
|
||||
buildHardwareAlerts,
|
||||
buildHardwareWebhookBody,
|
||||
buildHardwareNotificationMessage,
|
||||
buildWebhookBody,
|
||||
getTestMessage,
|
||||
} from "@/service/infrastructure/notificationProviders/utils.js";
|
||||
@@ -28,7 +28,7 @@ export class WebhookProvider implements INotificationProvider {
|
||||
}
|
||||
// For threshold breaches, use hardware alert format
|
||||
const { alertsToSend } = buildHardwareAlerts("HOST_PLACEHOLDER", monitor, monitorStatusResponse);
|
||||
const body = buildHardwareWebhookBody(clientHost, alertsToSend, monitor);
|
||||
const body = buildHardwareNotificationMessage(clientHost, alertsToSend, monitor);
|
||||
return body;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user