remove redundant method

This commit is contained in:
Alex Holliday
2026-02-16 00:17:51 +00:00
parent be8580ee99
commit 412a3b7cc9
5 changed files with 10 additions and 15 deletions
@@ -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;
};