aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-02-14 13:17:10 +0100
committerChocobozzz <me@florianbigard.com>2019-02-14 13:17:10 +0100
commit98d33a03d3a86aad709e2cd39a4e4d8bac6b7664 (patch)
treed8e1e8d21054fc4d966c009bdd05333a2a6e44cb /server/lib
parent73471b1a52f242e86364ffb077ea6cadb3b07ae2 (diff)
parent340f31ce96c456942fb01800f31d795e0f355d74 (diff)
downloadPeerTube-98d33a03d3a86aad709e2cd39a4e4d8bac6b7664.tar.gz
PeerTube-98d33a03d3a86aad709e2cd39a4e4d8bac6b7664.tar.zst
PeerTube-98d33a03d3a86aad709e2cd39a4e4d8bac6b7664.zip
Merge branch 'release/v1.2.0'
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/emailer.ts18
-rw-r--r--server/lib/job-queue/handlers/email.ts6
-rw-r--r--server/lib/notifier.ts2
3 files changed, 18 insertions, 8 deletions
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index f384a254e..99010f473 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -361,7 +361,8 @@ class Emailer {
361 'PeerTube.' 361 'PeerTube.'
362 362
363 const emailPayload: EmailPayload = { 363 const emailPayload: EmailPayload = {
364 from: fromEmail, 364 fromDisplayName: fromEmail,
365 replyTo: fromEmail,
365 to: [ CONFIG.ADMIN.EMAIL ], 366 to: [ CONFIG.ADMIN.EMAIL ],
366 subject: '[PeerTube] Contact form submitted', 367 subject: '[PeerTube] Contact form submitted',
367 text 368 text
@@ -370,16 +371,21 @@ class Emailer {
370 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 371 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
371 } 372 }
372 373
373 sendMail (to: string[], subject: string, text: string, from?: string) { 374 sendMail (options: EmailPayload) {
374 if (!Emailer.isEnabled()) { 375 if (!Emailer.isEnabled()) {
375 throw new Error('Cannot send mail because SMTP is not configured.') 376 throw new Error('Cannot send mail because SMTP is not configured.')
376 } 377 }
377 378
379 const fromDisplayName = options.fromDisplayName
380 ? options.fromDisplayName
381 : CONFIG.WEBSERVER.HOST
382
378 return this.transporter.sendMail({ 383 return this.transporter.sendMail({
379 from: from || CONFIG.SMTP.FROM_ADDRESS, 384 from: `"${fromDisplayName}" <${CONFIG.SMTP.FROM_ADDRESS}>`,
380 to: to.join(','), 385 replyTo: options.replyTo,
381 subject, 386 to: options.to.join(','),
382 text 387 subject: options.subject,
388 text: options.text
383 }) 389 })
384 } 390 }
385 391
diff --git a/server/lib/job-queue/handlers/email.ts b/server/lib/job-queue/handlers/email.ts
index 220d0af32..2ba39a156 100644
--- a/server/lib/job-queue/handlers/email.ts
+++ b/server/lib/job-queue/handlers/email.ts
@@ -6,14 +6,16 @@ export type EmailPayload = {
6 to: string[] 6 to: string[]
7 subject: string 7 subject: string
8 text: string 8 text: string
9 from?: string 9
10 fromDisplayName?: string
11 replyTo?: string
10} 12}
11 13
12async function processEmail (job: Bull.Job) { 14async function processEmail (job: Bull.Job) {
13 const payload = job.data as EmailPayload 15 const payload = job.data as EmailPayload
14 logger.info('Processing email in job %d.', job.id) 16 logger.info('Processing email in job %d.', job.id)
15 17
16 return Emailer.Instance.sendMail(payload.to, payload.subject, payload.text, payload.from) 18 return Emailer.Instance.sendMail(payload)
17} 19}
18 20
19// --------------------------------------------------------------------------- 21// ---------------------------------------------------------------------------
diff --git a/server/lib/notifier.ts b/server/lib/notifier.ts
index d1b331346..2fa320cd7 100644
--- a/server/lib/notifier.ts
+++ b/server/lib/notifier.ts
@@ -148,6 +148,8 @@ class Notifier {
148 148
149 private async notifyOfCommentMention (comment: VideoCommentModel) { 149 private async notifyOfCommentMention (comment: VideoCommentModel) {
150 const usernames = comment.extractMentions() 150 const usernames = comment.extractMentions()
151 logger.debug('Extracted %d username from comment %s.', usernames.length, comment.url, { usernames, text: comment.text })
152
151 let users = await UserModel.listByUsernames(usernames) 153 let users = await UserModel.listByUsernames(usernames)
152 154
153 if (comment.Video.isOwned()) { 155 if (comment.Video.isOwned()) {