diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/emailer.ts | 21 |
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 @@ | |||
1 | import { createTransport, Transporter } from 'nodemailer' | 1 | import { createTransport, Transporter } from 'nodemailer' |
2 | import { UserRight } from '../../shared/models/users' | ||
2 | import { isTestInstance } from '../helpers/core-utils' | 3 | import { isTestInstance } from '../helpers/core-utils' |
3 | import { logger } from '../helpers/logger' | 4 | import { logger } from '../helpers/logger' |
4 | import { CONFIG } from '../initializers' | 5 | import { CONFIG } from '../initializers' |
6 | import { UserModel } from '../models/account/user' | ||
7 | import { VideoModel } from '../models/video/video' | ||
5 | import { JobQueue } from './job-queue' | 8 | import { JobQueue } from './job-queue' |
6 | import { EmailPayload } from './job-queue/handlers/email' | 9 | import { EmailPayload } from './job-queue/handlers/email' |
7 | import { readFileSync } from 'fs' | 10 | import { 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.') |