aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/emailer.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index 317cec706..bc0061c99 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -1,7 +1,10 @@
1import { createTransport, Transporter } from 'nodemailer' 1import { createTransport, Transporter } from 'nodemailer'
2import { UserRight } from '../../shared/models/users'
2import { isTestInstance } from '../helpers/core-utils' 3import { isTestInstance } from '../helpers/core-utils'
3import { logger } from '../helpers/logger' 4import { logger } from '../helpers/logger'
4import { CONFIG } from '../initializers' 5import { CONFIG } from '../initializers'
6import { UserModel } from '../models/account/user'
7import { VideoModel } from '../models/video/video'
5import { JobQueue } from './job-queue' 8import { JobQueue } from './job-queue'
6import { EmailPayload } from './job-queue/handlers/email' 9import { EmailPayload } from './job-queue/handlers/email'
7import { readFileSync } from 'fs' 10import { readFileSync } from 'fs'
@@ -82,6 +85,24 @@ class Emailer {
82 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 85 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
83 } 86 }
84 87
88 async addVideoAbuseReport (videoId: number) {
89 const video = await VideoModel.load(videoId)
90
91 const text = `Hi,\n\n` +
92 `Your instance received an abuse for video the following video ${video.url}\n\n` +
93 `Cheers,\n` +
94 `PeerTube.`
95
96 const to = await UserModel.listEmailsWithRight(UserRight.MANAGE_VIDEO_ABUSES)
97 const emailPayload: EmailPayload = {
98 to,
99 subject: '[PeerTube] Received a video abuse',
100 text
101 }
102
103 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
104 }
105
85 sendMail (to: string[], subject: string, text: string) { 106 sendMail (to: string[], subject: string, text: string) {
86 if (!this.transporter) { 107 if (!this.transporter) {
87 throw new Error('Cannot send mail because SMTP is not configured.') 108 throw new Error('Cannot send mail because SMTP is not configured.')