feat(notifications): add option to send notifications for auto-approved requests

closes #267
This commit is contained in:
sct
2021-01-23 09:54:43 +00:00
parent d0c830e80d
commit 21db3676d1
7 changed files with 217 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
import logger from '../../logger';
import { getSettings } from '../settings';
import type { NotificationAgent, NotificationPayload } from './agents/agent';
export enum Notification {
@@ -43,11 +44,12 @@ class NotificationManager {
type: Notification,
payload: NotificationPayload
): void {
const settings = getSettings().notifications;
logger.info(`Sending notification for ${Notification[type]}`, {
label: 'Notifications',
});
this.activeAgents.forEach((agent) => {
if (agent.shouldSend(type)) {
if (settings.enabled && agent.shouldSend(type)) {
agent.send(type, payload);
}
});