1
0
Fork 0
peertube/server/lib/notifier/shared/abuse/new-abuse-message-for-reporter.ts
2021-08-02 10:39:51 +02:00

36 lines
1 KiB
TypeScript

import { logger } from '@server/helpers/logger'
import { getAbuseTargetUrl } from '@server/lib/activitypub/url'
import { UserModel } from '@server/models/user/user'
import { MUserDefault } from '@server/types/models'
import { AbstractNewAbuseMessage } from './abstract-new-abuse-message'
export class NewAbuseMessageForReporter extends AbstractNewAbuseMessage {
private reporter: MUserDefault
async prepare () {
// Only notify our users
if (this.abuse.ReporterAccount.isOwned() !== true) return
await this.loadMessageAccount()
const reporter = await UserModel.loadByAccountActorId(this.abuse.ReporterAccount.actorId)
// Don't notify my own message
if (reporter.Account.id === this.message.accountId) return
this.reporter = reporter
}
log () {
logger.info('Notifying reporter of new abuse message on %s.', getAbuseTargetUrl(this.abuse))
}
getTargetUsers () {
if (!this.reporter) return []
return [ this.reporter ]
}
createEmail (to: string) {
return this.createEmailFor(to, 'reporter')
}
}