aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/notifier.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-07-28 09:57:16 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-07-31 11:35:19 +0200
commitd573926e9b94fb19c8f51c53f71fc853182e1761 (patch)
tree907cc81c7275efe30aa90047c0763a7254bd1063 /server/lib/notifier.ts
parent594d3e48d8a887bbf48ce4cc594c1c36c9640fb1 (diff)
downloadPeerTube-d573926e9b94fb19c8f51c53f71fc853182e1761.tar.gz
PeerTube-d573926e9b94fb19c8f51c53f71fc853182e1761.tar.zst
PeerTube-d573926e9b94fb19c8f51c53f71fc853182e1761.zip
Add migrations for abuse messages
Diffstat (limited to 'server/lib/notifier.ts')
-rw-r--r--server/lib/notifier.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/server/lib/notifier.ts b/server/lib/notifier.ts
index 5c50fcf01..9c2f16c27 100644
--- a/server/lib/notifier.ts
+++ b/server/lib/notifier.ts
@@ -24,6 +24,7 @@ import { MCommentOwnerVideo, MVideoAccountLight, MVideoFullLight } from '../type
24import { isBlockedByServerOrAccount } from './blocklist' 24import { isBlockedByServerOrAccount } from './blocklist'
25import { Emailer } from './emailer' 25import { Emailer } from './emailer'
26import { PeerTubeSocket } from './peertube-socket' 26import { PeerTubeSocket } from './peertube-socket'
27import { AccountModel } from '@server/models/account/account'
27 28
28class Notifier { 29class Notifier {
29 30
@@ -137,7 +138,7 @@ class Notifier {
137 }) 138 })
138 } 139 }
139 140
140 notifyOnAbuseMessage (abuse: MAbuseFull, message: AbuseMessageModel): void { 141 notifyOnAbuseMessage (abuse: MAbuseFull, message: MAbuseMessage): void {
141 this.notifyOfNewAbuseMessage(abuse, message) 142 this.notifyOfNewAbuseMessage(abuse, message)
142 .catch(err => { 143 .catch(err => {
143 logger.error('Cannot notify on new abuse %d message.', abuse.id, { err }) 144 logger.error('Cannot notify on new abuse %d message.', abuse.id, { err })
@@ -436,6 +437,8 @@ class Notifier {
436 const url = this.getAbuseUrl(abuse) 437 const url = this.getAbuseUrl(abuse)
437 logger.info('Notifying reporter and moderators of new abuse message on %s.', url) 438 logger.info('Notifying reporter and moderators of new abuse message on %s.', url)
438 439
440 const accountMessage = await AccountModel.load(message.accountId)
441
439 function settingGetter (user: MUserWithNotificationSetting) { 442 function settingGetter (user: MUserWithNotificationSetting) {
440 return user.NotificationSetting.abuseNewMessage 443 return user.NotificationSetting.abuseNewMessage
441 } 444 }
@@ -452,11 +455,11 @@ class Notifier {
452 } 455 }
453 456
454 function emailSenderReporter (emails: string[]) { 457 function emailSenderReporter (emails: string[]) {
455 return Emailer.Instance.addAbuseNewMessageNotification(emails, { target: 'reporter', abuse, message }) 458 return Emailer.Instance.addAbuseNewMessageNotification(emails, { target: 'reporter', abuse, message, accountMessage })
456 } 459 }
457 460
458 function emailSenderModerators (emails: string[]) { 461 function emailSenderModerators (emails: string[]) {
459 return Emailer.Instance.addAbuseNewMessageNotification(emails, { target: 'moderator', abuse, message }) 462 return Emailer.Instance.addAbuseNewMessageNotification(emails, { target: 'moderator', abuse, message, accountMessage })
460 } 463 }
461 464
462 async function buildReporterOptions () { 465 async function buildReporterOptions () {