From eacb25c4366bcc8fba20f98f93f004fabc6d5578 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 8 Aug 2018 17:36:10 +0200 Subject: Add reason when banning a user --- server/lib/emailer.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'server/lib') diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts index ded321bf7..3faeffd77 100644 --- a/server/lib/emailer.ts +++ b/server/lib/emailer.ts @@ -89,7 +89,7 @@ class Emailer { return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) } - async addVideoAbuseReport (videoId: number) { + async addVideoAbuseReportJob (videoId: number) { const video = await VideoModel.load(videoId) if (!video) throw new Error('Unknown Video id during Abuse report.') @@ -108,6 +108,27 @@ class Emailer { return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) } + addUserBlockJob (user: UserModel, blocked: boolean, reason?: string) { + const reasonString = reason ? ` for the following reason: ${reason}` : '' + const blockedWord = blocked ? 'blocked' : 'unblocked' + const blockedString = `Your account ${user.username} on ${CONFIG.WEBSERVER.HOST} has been ${blockedWord}${reasonString}.` + + const text = 'Hi,\n\n' + + blockedString + + '\n\n' + + 'Cheers,\n' + + `PeerTube.` + + const to = user.email + const emailPayload: EmailPayload = { + to: [ to ], + subject: '[PeerTube] Account ' + blockedWord, + text + } + + return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) + } + sendMail (to: string[], subject: string, text: string) { if (!this.transporter) { throw new Error('Cannot send mail because SMTP is not configured.') -- cgit v1.2.3