feat(notifications): control notifcation types per agent

closes #513
This commit is contained in:
sct
2020-12-28 02:21:45 +00:00
parent d00e470b55
commit 8af6a1f566
12 changed files with 410 additions and 91 deletions

View File

@@ -1,5 +1,5 @@
import axios from 'axios';
import { Notification } from '..';
import { hasNotificationType, Notification } from '..';
import logger from '../../../logger';
import { getSettings, NotificationAgentTelegram } from '../../settings';
import { BaseAgent, NotificationAgent, NotificationPayload } from './agent';
@@ -25,13 +25,12 @@ class TelegramAgent
return settings.notifications.agents.telegram;
}
// TODO: Add checking for type here once we add notification type filters for agents
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public shouldSend(_type: Notification): boolean {
public shouldSend(type: Notification): boolean {
if (
this.getSettings().enabled &&
this.getSettings().options.botAPI &&
this.getSettings().options.chatId
this.getSettings().options.chatId &&
hasNotificationType(type, this.getSettings().types)
) {
return true;
}