]>
Commit | Line | Data |
---|---|---|
1 | import { logger } from '@server/helpers/logger' | |
2 | import { getAbuseTargetUrl } from '@server/lib/activitypub/url' | |
3 | import { UserModel } from '@server/models/user/user' | |
4 | import { MUserDefault } from '@server/types/models' | |
5 | import { UserRight } from '@shared/models' | |
6 | import { AbstractNewAbuseMessage } from './abstract-new-abuse-message' | |
7 | ||
8 | export class NewAbuseMessageForModerators extends AbstractNewAbuseMessage { | |
9 | private moderators: MUserDefault[] | |
10 | ||
11 | async prepare () { | |
12 | this.moderators = await UserModel.listWithRight(UserRight.MANAGE_ABUSES) | |
13 | ||
14 | // Don't notify my own message | |
15 | this.moderators = this.moderators.filter(m => m.Account.id !== this.message.accountId) | |
16 | if (this.moderators.length === 0) return | |
17 | ||
18 | await this.loadMessageAccount() | |
19 | } | |
20 | ||
21 | log () { | |
22 | logger.info('Notifying moderators of new abuse message on %s.', getAbuseTargetUrl(this.abuse)) | |
23 | } | |
24 | ||
25 | getTargetUsers () { | |
26 | return this.moderators | |
27 | } | |
28 | ||
29 | createEmail (to: string) { | |
30 | return this.createEmailFor(to, 'moderator') | |
31 | } | |
32 | } |