+ if (abuseInstance.VideoAbuse) {
+ const video = abuseInstance.VideoAbuse.Video
+ const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
+
+ emailPayload = {
+ template: 'video-abuse-new',
+ to,
+ subject: `New video abuse report from ${reporter}`,
+ locals: {
+ videoUrl,
+ isLocal: video.remote === false,
+ videoCreatedAt: new Date(video.createdAt).toLocaleString(),
+ videoPublishedAt: new Date(video.publishedAt).toLocaleString(),
+ videoName: video.name,
+ reason: abuse.reason,
+ videoChannel: abuse.video.channel,
+ reporter,
+ action
+ }
+ }
+ } else if (abuseInstance.VideoCommentAbuse) {
+ const comment = abuseInstance.VideoCommentAbuse.VideoComment
+ const commentUrl = WEBSERVER.URL + comment.Video.getWatchStaticPath() + ';threadId=' + comment.getThreadId()
+
+ emailPayload = {
+ template: 'video-comment-abuse-new',
+ to,
+ subject: `New comment abuse report from ${reporter}`,
+ locals: {
+ commentUrl,
+ videoName: comment.Video.name,
+ isLocal: comment.isOwned(),
+ commentCreatedAt: new Date(comment.createdAt).toLocaleString(),
+ reason: abuse.reason,
+ flaggedAccount: abuseInstance.FlaggedAccount.getDisplayName(),
+ reporter,
+ action
+ }
+ }
+ } else {
+ const account = abuseInstance.FlaggedAccount
+ const accountUrl = account.getClientUrl()
+
+ emailPayload = {
+ template: 'account-abuse-new',
+ to,
+ subject: `New account abuse report from ${reporter}`,
+ locals: {
+ accountUrl,
+ accountDisplayName: account.getDisplayName(),
+ isLocal: account.isOwned(),
+ reason: abuse.reason,
+ reporter,
+ action
+ }
+ }
+ }
+
+ return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
+ }
+
+ addAbuseStateChangeNotification (to: string[], abuse: MAbuseFull) {
+ const text = abuse.state === AbuseState.ACCEPTED
+ ? 'Report #' + abuse.id + ' has been accepted'
+ : 'Report #' + abuse.id + ' has been rejected'
+
+ const abuseUrl = WEBSERVER.URL + '/my-account/abuses?search=%23' + abuse.id
+
+ const action = {
+ text,
+ url: abuseUrl
+ }