From d26836cd95e981d636006652927773c7943e77ce Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 30 Jul 2021 16:51:27 +0200 Subject: Refactor notifier --- .../shared/common/abstract-notification.ts | 23 ++++++++++++++++++++++ server/lib/notifier/shared/common/index.ts | 1 + 2 files changed, 24 insertions(+) create mode 100644 server/lib/notifier/shared/common/abstract-notification.ts create mode 100644 server/lib/notifier/shared/common/index.ts (limited to 'server/lib/notifier/shared/common') diff --git a/server/lib/notifier/shared/common/abstract-notification.ts b/server/lib/notifier/shared/common/abstract-notification.ts new file mode 100644 index 000000000..53e2e02d5 --- /dev/null +++ b/server/lib/notifier/shared/common/abstract-notification.ts @@ -0,0 +1,23 @@ +import { MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models' +import { EmailPayload, UserNotificationSettingValue } from '@shared/models' + +export abstract class AbstractNotification { + + constructor (protected readonly payload: T) { + + } + + abstract prepare (): Promise + abstract log (): void + + abstract getSetting (user: U): UserNotificationSettingValue + abstract getTargetUsers (): U[] + + abstract createNotification (user: U): Promise + abstract createEmail (to: string): EmailPayload | Promise + + isDisabled (): boolean | Promise { + return false + } + +} diff --git a/server/lib/notifier/shared/common/index.ts b/server/lib/notifier/shared/common/index.ts new file mode 100644 index 000000000..0b2570278 --- /dev/null +++ b/server/lib/notifier/shared/common/index.ts @@ -0,0 +1 @@ +export * from './abstract-notification' -- cgit v1.2.3