aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/notifier/shared/common
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-30 16:51:27 +0200
committerChocobozzz <me@florianbigard.com>2021-08-02 10:39:51 +0200
commitd26836cd95e981d636006652927773c7943e77ce (patch)
tree934a4a835bfddbf1c2c7da98d84ebd7623d60d49 /server/lib/notifier/shared/common
parent2bee9db56ade2b3b1bb0efa8716840d87efdb93f (diff)
downloadPeerTube-d26836cd95e981d636006652927773c7943e77ce.tar.gz
PeerTube-d26836cd95e981d636006652927773c7943e77ce.tar.zst
PeerTube-d26836cd95e981d636006652927773c7943e77ce.zip
Refactor notifier
Diffstat (limited to 'server/lib/notifier/shared/common')
-rw-r--r--server/lib/notifier/shared/common/abstract-notification.ts23
-rw-r--r--server/lib/notifier/shared/common/index.ts1
2 files changed, 24 insertions, 0 deletions
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 @@
1import { MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models'
2import { EmailPayload, UserNotificationSettingValue } from '@shared/models'
3
4export abstract class AbstractNotification <T, U = MUserWithNotificationSetting> {
5
6 constructor (protected readonly payload: T) {
7
8 }
9
10 abstract prepare (): Promise<void>
11 abstract log (): void
12
13 abstract getSetting (user: U): UserNotificationSettingValue
14 abstract getTargetUsers (): U[]
15
16 abstract createNotification (user: U): Promise<UserNotificationModelForApi>
17 abstract createEmail (to: string): EmailPayload | Promise<EmailPayload>
18
19 isDisabled (): boolean | Promise<boolean> {
20 return false
21 }
22
23}
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'