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.ts30
1 files changed, 22 insertions, 8 deletions
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index 9c49aa2f6..25b0aaedd 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -11,7 +11,7 @@ import { isTestInstance, root } from '../helpers/core-utils'
11import { bunyanLogger, logger } from '../helpers/logger' 11import { bunyanLogger, logger } from '../helpers/logger'
12import { CONFIG, isEmailEnabled } from '../initializers/config' 12import { CONFIG, isEmailEnabled } from '../initializers/config'
13import { WEBSERVER } from '../initializers/constants' 13import { WEBSERVER } from '../initializers/constants'
14import { MAbuseFull, MAbuseMessage, MActorFollowActors, MActorFollowFull, MUser } from '../types/models' 14import { MAbuseFull, MAbuseMessage, MAccountDefault, MActorFollowActors, MActorFollowFull, MUser } from '../types/models'
15import { MCommentOwnerVideo, MVideo, MVideoAccountLight } from '../types/models/video' 15import { MCommentOwnerVideo, MVideo, MVideoAccountLight } from '../types/models/video'
16import { JobQueue } from './job-queue' 16import { JobQueue } from './job-queue'
17 17
@@ -362,9 +362,11 @@ class Emailer {
362 ? 'Report #' + abuse.id + ' has been accepted' 362 ? 'Report #' + abuse.id + ' has been accepted'
363 : 'Report #' + abuse.id + ' has been rejected' 363 : 'Report #' + abuse.id + ' has been rejected'
364 364
365 const abuseUrl = WEBSERVER.URL + '/my-account/abuses?search=%23' + abuse.id
366
365 const action = { 367 const action = {
366 text, 368 text,
367 url: WEBSERVER.URL + '/my-account/abuses?search=%23' + abuse.id 369 url: abuseUrl
368 } 370 }
369 371
370 const emailPayload: EmailPayload = { 372 const emailPayload: EmailPayload = {
@@ -374,6 +376,7 @@ class Emailer {
374 locals: { 376 locals: {
375 action, 377 action,
376 abuseId: abuse.id, 378 abuseId: abuse.id,
379 abuseUrl,
377 isAccepted: abuse.state === AbuseState.ACCEPTED 380 isAccepted: abuse.state === AbuseState.ACCEPTED
378 } 381 }
379 } 382 }
@@ -381,15 +384,24 @@ class Emailer {
381 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 384 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
382 } 385 }
383 386
384 addAbuseNewMessageNotification (to: string[], options: { target: 'moderator' | 'reporter', abuse: MAbuseFull, message: MAbuseMessage }) { 387 addAbuseNewMessageNotification (
385 const { abuse, target, message } = options 388 to: string[],
389 options: {
390 target: 'moderator' | 'reporter'
391 abuse: MAbuseFull
392 message: MAbuseMessage
393 accountMessage: MAccountDefault
394 }) {
395 const { abuse, target, message, accountMessage } = options
396
397 const text = 'New message on report #' + abuse.id
398 const abuseUrl = target === 'moderator'
399 ? WEBSERVER.URL + '/admin/moderation/abuses/list?search=%23' + abuse.id
400 : WEBSERVER.URL + '/my-account/abuses?search=%23' + abuse.id
386 401
387 const text = 'New message on abuse #' + abuse.id
388 const action = { 402 const action = {
389 text, 403 text,
390 url: target === 'moderator' 404 url: abuseUrl
391 ? WEBSERVER.URL + '/admin/moderation/abuses/list?search=%23' + abuse.id
392 : WEBSERVER.URL + '/my-account/abuses?search=%23' + abuse.id
393 } 405 }
394 406
395 const emailPayload: EmailPayload = { 407 const emailPayload: EmailPayload = {
@@ -397,7 +409,9 @@ class Emailer {
397 to, 409 to,
398 subject: text, 410 subject: text,
399 locals: { 411 locals: {
412 abuseId: abuse.id,
400 abuseUrl: action.url, 413 abuseUrl: action.url,
414 messageAccountName: accountMessage.getDisplayName(),
401 messageText: message.message, 415 messageText: message.message,
402 action 416 action
403 } 417 }