notificaiton providers

This commit is contained in:
Alex Holliday
2026-03-03 23:27:48 +00:00
parent 00150ba6f4
commit af8b128ac2
4 changed files with 12 additions and 16 deletions
@@ -1,15 +1,15 @@
const SERVICE_NAME = "SlackProvider";
import type { Monitor, Notification, MonitorStatusResponse } from "@/types/index.js";
import type { Notification } from "@/types/index.js";
import { INotificationProvider } from "@/service/index.js";
import type { MonitorActionDecision } from "@/service/infrastructure/SuperSimpleQueue/SuperSimpleQueueHelper.js";
import type { NotificationMessage } from "@/types/notificationMessage.js";
import { getTestMessage } from "@/service/infrastructure/notificationProviders/utils.js";
import got, { HTTPError } from "got";
import { ILogger } from "@/utils/logger.js";
export class SlackProvider implements INotificationProvider {
private logger: any;
private logger: ILogger;
constructor(logger: any) {
constructor(logger: ILogger) {
this.logger = logger;
}
@@ -78,7 +78,7 @@ export class SlackProvider implements INotificationProvider {
* Uses Slack's rich formatting with sections, fields, and context blocks
*/
private buildSlackPayload(message: NotificationMessage): object {
const blocks: any[] = [];
const blocks: unknown[] = [];
// Determine color based on severity
const colorMap = {
@@ -1,6 +1,6 @@
import { Monitor, HardwareStatusPayload, MonitorStatusResponse } from "@/types/index.js";
import EmailService from "@/service/infrastructure/emailService.js";
// Test notification helpers - used by all providers for test alerts
export const buildTestEmail = async (emailService: any) => {
export const buildTestEmail = async (emailService: EmailService) => {
const context = { testName: "Monitoring System" };
const html = await emailService.buildEmail("testEmailTemplate", context);
return html;
@@ -1,15 +1,15 @@
const SERVICE_NAME = "WebhookProvider";
import type { Monitor, Alert, Notification, MonitorStatusResponse } from "@/types/index.js";
import type { Notification } from "@/types/index.js";
import { INotificationProvider } from "@/service/index.js";
import type { MonitorActionDecision } from "@/service/infrastructure/SuperSimpleQueue/SuperSimpleQueueHelper.js";
import type { NotificationMessage } from "@/types/notificationMessage.js";
import { getTestMessage } from "@/service/infrastructure/notificationProviders/utils.js";
import got from "got";
import { ILogger } from "@/utils/logger.js";
export class WebhookProvider implements INotificationProvider {
private logger: any;
private logger: ILogger;
constructor(logger: any) {
constructor(logger: ILogger) {
this.logger = logger;
}
@@ -46,10 +46,6 @@ export class WebhookProvider implements INotificationProvider {
}
};
/**
* Build webhook payload from NotificationMessage
* Format: { text: string, severity: string, monitor: object, details: object }
*/
private buildWebhookPayload(message: NotificationMessage): object {
const lines: string[] = [];
@@ -1,4 +1,4 @@
import type { HardwareStatusPayload, Monitor, MonitorStatusResponse, Notification, MonitorStatus } from "@/types/index.js";
import type { Monitor, MonitorStatusResponse, Notification } from "@/types/index.js";
import type { NotificationMessage } from "@/types/notificationMessage.js";
import { IMonitorsRepository, INotificationsRepository } from "@/repositories/index.js";
import { INotificationProvider } from "./notificationProviders/INotificationProvider.js";