diff options
author | Chocobozzz <me@florianbigard.com> | 2020-07-28 09:57:16 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-07-31 11:35:19 +0200 |
commit | d573926e9b94fb19c8f51c53f71fc853182e1761 (patch) | |
tree | 907cc81c7275efe30aa90047c0763a7254bd1063 /server/lib/emailer.ts | |
parent | 594d3e48d8a887bbf48ce4cc594c1c36c9640fb1 (diff) | |
download | PeerTube-d573926e9b94fb19c8f51c53f71fc853182e1761.tar.gz PeerTube-d573926e9b94fb19c8f51c53f71fc853182e1761.tar.zst PeerTube-d573926e9b94fb19c8f51c53f71fc853182e1761.zip |
Add migrations for abuse messages
Diffstat (limited to 'server/lib/emailer.ts')
-rw-r--r-- | server/lib/emailer.ts | 30 |
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' | |||
11 | import { bunyanLogger, logger } from '../helpers/logger' | 11 | import { bunyanLogger, logger } from '../helpers/logger' |
12 | import { CONFIG, isEmailEnabled } from '../initializers/config' | 12 | import { CONFIG, isEmailEnabled } from '../initializers/config' |
13 | import { WEBSERVER } from '../initializers/constants' | 13 | import { WEBSERVER } from '../initializers/constants' |
14 | import { MAbuseFull, MAbuseMessage, MActorFollowActors, MActorFollowFull, MUser } from '../types/models' | 14 | import { MAbuseFull, MAbuseMessage, MAccountDefault, MActorFollowActors, MActorFollowFull, MUser } from '../types/models' |
15 | import { MCommentOwnerVideo, MVideo, MVideoAccountLight } from '../types/models/video' | 15 | import { MCommentOwnerVideo, MVideo, MVideoAccountLight } from '../types/models/video' |
16 | import { JobQueue } from './job-queue' | 16 | import { 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 | } |