diff options
Diffstat (limited to 'server/lib/notifier/shared/instance/new-plugin-version-for-admins.ts')
-rw-r--r-- | server/lib/notifier/shared/instance/new-plugin-version-for-admins.ts | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/server/lib/notifier/shared/instance/new-plugin-version-for-admins.ts b/server/lib/notifier/shared/instance/new-plugin-version-for-admins.ts deleted file mode 100644 index 547c6726c..000000000 --- a/server/lib/notifier/shared/instance/new-plugin-version-for-admins.ts +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | import { logger } from '@server/helpers/logger' | ||
2 | import { WEBSERVER } from '@server/initializers/constants' | ||
3 | import { UserModel } from '@server/models/user/user' | ||
4 | import { UserNotificationModel } from '@server/models/user/user-notification' | ||
5 | import { MPlugin, MUserDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models' | ||
6 | import { UserNotificationType, UserRight } from '@shared/models' | ||
7 | import { AbstractNotification } from '../common/abstract-notification' | ||
8 | |||
9 | export class NewPluginVersionForAdmins extends AbstractNotification <MPlugin> { | ||
10 | private admins: MUserDefault[] | ||
11 | |||
12 | async prepare () { | ||
13 | // Use the debug right to know who is an administrator | ||
14 | this.admins = await UserModel.listWithRight(UserRight.MANAGE_DEBUG) | ||
15 | } | ||
16 | |||
17 | log () { | ||
18 | logger.info('Notifying %s admins of new PeerTube version %s.', this.admins.length, this.payload.latestVersion) | ||
19 | } | ||
20 | |||
21 | getSetting (user: MUserWithNotificationSetting) { | ||
22 | return user.NotificationSetting.newPluginVersion | ||
23 | } | ||
24 | |||
25 | getTargetUsers () { | ||
26 | return this.admins | ||
27 | } | ||
28 | |||
29 | createNotification (user: MUserWithNotificationSetting) { | ||
30 | const notification = UserNotificationModel.build<UserNotificationModelForApi>({ | ||
31 | type: UserNotificationType.NEW_PLUGIN_VERSION, | ||
32 | userId: user.id, | ||
33 | pluginId: this.plugin.id | ||
34 | }) | ||
35 | notification.Plugin = this.plugin | ||
36 | |||
37 | return notification | ||
38 | } | ||
39 | |||
40 | createEmail (to: string) { | ||
41 | const pluginUrl = WEBSERVER.URL + '/admin/plugins/list-installed?pluginType=' + this.plugin.type | ||
42 | |||
43 | return { | ||
44 | to, | ||
45 | template: 'plugin-version-new', | ||
46 | subject: `A new plugin/theme version is available: ${this.plugin.name}@${this.plugin.latestVersion}`, | ||
47 | locals: { | ||
48 | pluginName: this.plugin.name, | ||
49 | latestVersion: this.plugin.latestVersion, | ||
50 | pluginUrl | ||
51 | } | ||
52 | } | ||
53 | } | ||
54 | |||
55 | private get plugin () { | ||
56 | return this.payload | ||
57 | } | ||
58 | } | ||