diff options
Diffstat (limited to 'server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.ts')
-rw-r--r-- | server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.ts b/server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.ts new file mode 100644 index 000000000..9d0629690 --- /dev/null +++ b/server/lib/notifier/shared/abuse/new-abuse-message-for-moderators.ts | |||
@@ -0,0 +1,32 @@ | |||
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 | } | ||