PeerTube/server/lib/notifier/shared/abuse/new-abuse-message-for-moder...

33 lines
1010 B
TypeScript
Raw Normal View History

2021-07-30 09:51:27 -05:00
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 { UserRight } from '@shared/models'
import { AbstractNewAbuseMessage } from './abstract-new-abuse-message'
export class NewAbuseMessageForModerators extends AbstractNewAbuseMessage {
private moderators: MUserDefault[]
async prepare () {
this.moderators = await UserModel.listWithRight(UserRight.MANAGE_ABUSES)
// Don't notify my own message
this.moderators = this.moderators.filter(m => m.Account.id !== this.message.accountId)
if (this.moderators.length === 0) return
await this.loadMessageAccount()
}
log () {
logger.info('Notifying moderators of new abuse message on %s.', getAbuseTargetUrl(this.abuse))
}
getTargetUsers () {
return this.moderators
}
createEmail (to: string) {
return this.createEmailFor(to, 'moderator')
}
}