notificaiton providers
This commit is contained in:
1 parent
00150ba6f4
commit
af8b128ac2
4 files changed
+12
-16
No files matched your search
@@ -1,15 +1,15 @@
|
|||||||
const SERVICE_NAME = "SlackProvider";
|
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 { INotificationProvider } from "@/service/index.js";
|
||||||
import type { MonitorActionDecision } from "@/service/infrastructure/SuperSimpleQueue/SuperSimpleQueueHelper.js";
|
|
||||||
import type { NotificationMessage } from "@/types/notificationMessage.js";
|
import type { NotificationMessage } from "@/types/notificationMessage.js";
|
||||||
import { getTestMessage } from "@/service/infrastructure/notificationProviders/utils.js";
|
import { getTestMessage } from "@/service/infrastructure/notificationProviders/utils.js";
|
||||||
import got, { HTTPError } from "got";
|
import got, { HTTPError } from "got";
|
||||||
|
import { ILogger } from "@/utils/logger.js";
|
||||||
|
|
||||||
export class SlackProvider implements INotificationProvider {
|
export class SlackProvider implements INotificationProvider {
|
||||||
private logger: any;
|
private logger: ILogger;
|
||||||
|
|
||||||
constructor(logger: any) {
|
constructor(logger: ILogger) {
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ export class SlackProvider implements INotificationProvider {
|
|||||||
* Uses Slack's rich formatting with sections, fields, and context blocks
|
* Uses Slack's rich formatting with sections, fields, and context blocks
|
||||||
*/
|
*/
|
||||||
private buildSlackPayload(message: NotificationMessage): object {
|
private buildSlackPayload(message: NotificationMessage): object {
|
||||||
const blocks: any[] = [];
|
const blocks: unknown[] = [];
|
||||||
|
|
||||||
// Determine color based on severity
|
// Determine color based on severity
|
||||||
const colorMap = {
|
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
|
// 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 context = { testName: "Monitoring System" };
|
||||||
const html = await emailService.buildEmail("testEmailTemplate", context);
|
const html = await emailService.buildEmail("testEmailTemplate", context);
|
||||||
return html;
|
return html;
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
const SERVICE_NAME = "WebhookProvider";
|
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 { INotificationProvider } from "@/service/index.js";
|
||||||
import type { MonitorActionDecision } from "@/service/infrastructure/SuperSimpleQueue/SuperSimpleQueueHelper.js";
|
|
||||||
import type { NotificationMessage } from "@/types/notificationMessage.js";
|
import type { NotificationMessage } from "@/types/notificationMessage.js";
|
||||||
import { getTestMessage } from "@/service/infrastructure/notificationProviders/utils.js";
|
import { getTestMessage } from "@/service/infrastructure/notificationProviders/utils.js";
|
||||||
import got from "got";
|
import got from "got";
|
||||||
|
import { ILogger } from "@/utils/logger.js";
|
||||||
|
|
||||||
export class WebhookProvider implements INotificationProvider {
|
export class WebhookProvider implements INotificationProvider {
|
||||||
private logger: any;
|
private logger: ILogger;
|
||||||
|
|
||||||
constructor(logger: any) {
|
constructor(logger: ILogger) {
|
||||||
this.logger = logger;
|
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 {
|
private buildWebhookPayload(message: NotificationMessage): object {
|
||||||
const lines: string[] = [];
|
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 type { NotificationMessage } from "@/types/notificationMessage.js";
|
||||||
import { IMonitorsRepository, INotificationsRepository } from "@/repositories/index.js";
|
import { IMonitorsRepository, INotificationsRepository } from "@/repositories/index.js";
|
||||||
import { INotificationProvider } from "./notificationProviders/INotificationProvider.js";
|
import { INotificationProvider } from "./notificationProviders/INotificationProvider.js";
|
||||||
|
|||||||
Reference in new issue
Block a user