notification provider

This commit is contained in:
Alex Holliday
2026-01-18 16:34:20 +00:00
parent a0ebf7d224
commit cff5508614
5 changed files with 38 additions and 7 deletions
+2 -2
View File
@@ -50,7 +50,7 @@ import StatusPage from "../db/models/StatusPage.js";
import Team from "../db/models/Team.js";
import MaintenanceWindow from "../db/models/MaintenanceWindow.js";
import MonitorStats from "../db/models/MonitorStats.js";
import Notification from "../db/models/Notification.js";
import NotificationModel from "../db/models/Notification.js";
import RecoveryToken from "../db/models/RecoveryToken.js";
import AppSettings from "../db/models/AppSettings.js";
import Incident from "../db/models/Incident.js";
@@ -141,7 +141,7 @@ export const initializeServices = async ({
const statusPageModule = new StatusPageModule({ StatusPage, NormalizeData, stringService, AppSettings });
const userModule = new UserModule({ User, Team, GenerateAvatarImage, ParseBoolean, stringService });
const maintenanceWindowModule = new MaintenanceWindowModule({ MaintenanceWindow });
const notificationModule = new NotificationModule({ Notification, Monitor });
const notificationModule = new NotificationModule({ Notification: NotificationModel, Monitor });
const recoveryModule = new RecoveryModule({ User, RecoveryToken, crypto, stringService });
const settingsModule = new SettingsModule({ AppSettings });
const incidentModule = new IncidentModule({ logger, Incident, Monitor, User });
@@ -1,5 +1,3 @@
// import Notification from "../../models/Notification.js";
// import Monitor from "../../models/Monitor.js";
const SERVICE_NAME = "notificationModule";
class NotificationModule {
@@ -1,4 +1,7 @@
import type { Monitor } from "@/types/index.js";
import type { Monitor, Notification, Alert } from "@/types/index.js";
export interface IAlert {}
export interface IMessageProvider {}
export interface IMessageProvider {
buildAlert: (monitor: Monitor) => Alert;
sendAlert: (alert: Alert, notification: Notification) => Promise<boolean>;
sendTestAlert(notification: Notification): Promise<boolean>;
}
+29
View File
@@ -0,0 +1,29 @@
import { NotificationChannel } from "@/types/index.js";
export interface AlertWebhookPayload {
body: Record<string, unknown>;
}
export interface AlertPagerDutyPayload {
routingKey: string;
monitorUrl?: string;
}
export interface AlertMatrixPayload {
friendlyName?: string;
homeserverUrl: string;
accessToken: string;
roomId: string;
monitorName: string;
}
export interface Alert {
channel: NotificationChannel;
address?: string;
subject: string;
message: string;
html?: string;
discordContent?: Record<string, unknown> | null;
webhook?: AlertWebhookPayload | null;
pagerDuty?: AlertPagerDutyPayload | null;
matrix?: AlertMatrixPayload | null;
}
+1
View File
@@ -8,3 +8,4 @@ export * from "@/types/invite.js";
export * from "@/types/recoveryToken.js";
export * from "@/types/settings.js";
export * from "@/types/notification.js";
export * from "@/types/alert.js";