]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/notifier/shared/abuse/new-abuse-message-for-reporter.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / server / lib / notifier / shared / abuse / new-abuse-message-for-reporter.ts
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 { AbstractNewAbuseMessage } from './abstract-new-abuse-message'
6
7 export class NewAbuseMessageForReporter extends AbstractNewAbuseMessage {
8 private reporter: MUserDefault
9
10 async prepare () {
11 // Only notify our users
12 if (this.abuse.ReporterAccount.isOwned() !== true) return
13
14 await this.loadMessageAccount()
15
16 const reporter = await UserModel.loadByAccountActorId(this.abuse.ReporterAccount.actorId)
17 // Don't notify my own message
18 if (reporter.Account.id === this.message.accountId) return
19
20 this.reporter = reporter
21 }
22
23 log () {
24 logger.info('Notifying reporter of new abuse message on %s.', getAbuseTargetUrl(this.abuse))
25 }
26
27 getTargetUsers () {
28 if (!this.reporter) return []
29
30 return [ this.reporter ]
31 }
32
33 createEmail (to: string) {
34 return this.createEmailFor(to, 'reporter')
35 }
36 }