aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/emailer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/emailer.ts')
-rw-r--r--server/lib/emailer.ts23
1 files changed, 22 insertions, 1 deletions
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 {
89 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 89 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
90 } 90 }
91 91
92 async addVideoAbuseReport (videoId: number) { 92 async addVideoAbuseReportJob (videoId: number) {
93 const video = await VideoModel.load(videoId) 93 const video = await VideoModel.load(videoId)
94 if (!video) throw new Error('Unknown Video id during Abuse report.') 94 if (!video) throw new Error('Unknown Video id during Abuse report.')
95 95
@@ -108,6 +108,27 @@ class Emailer {
108 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 108 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
109 } 109 }
110 110
111 addUserBlockJob (user: UserModel, blocked: boolean, reason?: string) {
112 const reasonString = reason ? ` for the following reason: ${reason}` : ''
113 const blockedWord = blocked ? 'blocked' : 'unblocked'
114 const blockedString = `Your account ${user.username} on ${CONFIG.WEBSERVER.HOST} has been ${blockedWord}${reasonString}.`
115
116 const text = 'Hi,\n\n' +
117 blockedString +
118 '\n\n' +
119 'Cheers,\n' +
120 `PeerTube.`
121
122 const to = user.email
123 const emailPayload: EmailPayload = {
124 to: [ to ],
125 subject: '[PeerTube] Account ' + blockedWord,
126 text
127 }
128
129 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
130 }
131
111 sendMail (to: string[], subject: string, text: string) { 132 sendMail (to: string[], subject: string, text: string) {
112 if (!this.transporter) { 133 if (!this.transporter) {
113 throw new Error('Cannot send mail because SMTP is not configured.') 134 throw new Error('Cannot send mail because SMTP is not configured.')