notification provider
This commit is contained in:
1 parent
a0ebf7d224
commit
cff5508614
5 files changed
+38
-7
No files matched your search
@@ -50,7 +50,7 @@ import StatusPage from "../db/models/StatusPage.js";
|
|||||||
import Team from "../db/models/Team.js";
|
import Team from "../db/models/Team.js";
|
||||||
import MaintenanceWindow from "../db/models/MaintenanceWindow.js";
|
import MaintenanceWindow from "../db/models/MaintenanceWindow.js";
|
||||||
import MonitorStats from "../db/models/MonitorStats.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 RecoveryToken from "../db/models/RecoveryToken.js";
|
||||||
import AppSettings from "../db/models/AppSettings.js";
|
import AppSettings from "../db/models/AppSettings.js";
|
||||||
import Incident from "../db/models/Incident.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 statusPageModule = new StatusPageModule({ StatusPage, NormalizeData, stringService, AppSettings });
|
||||||
const userModule = new UserModule({ User, Team, GenerateAvatarImage, ParseBoolean, stringService });
|
const userModule = new UserModule({ User, Team, GenerateAvatarImage, ParseBoolean, stringService });
|
||||||
const maintenanceWindowModule = new MaintenanceWindowModule({ MaintenanceWindow });
|
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 recoveryModule = new RecoveryModule({ User, RecoveryToken, crypto, stringService });
|
||||||
const settingsModule = new SettingsModule({ AppSettings });
|
const settingsModule = new SettingsModule({ AppSettings });
|
||||||
const incidentModule = new IncidentModule({ logger, Incident, Monitor, User });
|
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";
|
const SERVICE_NAME = "notificationModule";
|
||||||
|
|
||||||
class 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>;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -8,3 +8,4 @@ export * from "@/types/invite.js";
|
|||||||
export * from "@/types/recoveryToken.js";
|
export * from "@/types/recoveryToken.js";
|
||||||
export * from "@/types/settings.js";
|
export * from "@/types/settings.js";
|
||||||
export * from "@/types/notification.js";
|
export * from "@/types/notification.js";
|
||||||
|
export * from "@/types/alert.js";
|
||||||
Reference in new issue
Block a user