Skip to content

Commit

Permalink
Render comment in notification email
Browse files Browse the repository at this point in the history
  • Loading branch information
Kimsible committed Nov 5, 2020
1 parent 861a188 commit d688ef0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions server/lib/emailer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { MAbuseFull, MAbuseMessage, MAccountDefault, MActorFollowActors, MActorF
import { MCommentOwnerVideo, MVideo, MVideoAccountLight } from '../types/models/video'
import { JobQueue } from './job-queue'

const marked = require('marked')
const Email = require('email-templates')

class Emailer {
Expand Down Expand Up @@ -236,6 +237,7 @@ class Emailer {
const video = comment.Video
const videoUrl = WEBSERVER.URL + comment.Video.getWatchStaticPath()
const commentUrl = WEBSERVER.URL + comment.getCommentStaticPath()
const commentText = marked(comment.text)

const emailPayload: EmailPayload = {
template: 'video-comment-new',
Expand All @@ -245,6 +247,7 @@ class Emailer {
accountName: comment.Account.getDisplayName(),
accountUrl: comment.Account.Actor.url,
comment,
commentText,
video,
videoUrl,
action: {
Expand All @@ -262,13 +265,15 @@ class Emailer {
const video = comment.Video
const videoUrl = WEBSERVER.URL + comment.Video.getWatchStaticPath()
const commentUrl = WEBSERVER.URL + comment.getCommentStaticPath()
const commentText = marked(comment.text)

const emailPayload: EmailPayload = {
template: 'video-comment-mention',
to,
subject: 'Mention on video ' + video.name,
locals: {
comment,
commentText,
video,
videoUrl,
accountName,
Expand Down
6 changes: 3 additions & 3 deletions server/lib/emails/video-comment-mention/html.pug
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ block title

block content
p.
#[a(href=accountUrl title=handle) #{accountName}] mentioned you in a comment on video
#[a(href=accountUrl title=handle) #{accountName}] mentioned you in a comment on video
"#[a(href=videoUrl) #{video.name}]":
blockquote #{comment.text}
br(style="display: none;")
blockquote !{commentText}
br(style="display: none;")
6 changes: 3 additions & 3 deletions server/lib/emails/video-comment-new/html.pug
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ block title

block content
p.
#[a(href=accountUrl title=handle) #{accountName}] added a comment on your video
#[a(href=accountUrl title=handle) #{accountName}] added a comment on your video
"#[a(href=videoUrl) #{video.name}]":
blockquote #{comment.text}
br(style="display: none;")
blockquote !{commentText}
br(style="display: none;")

0 comments on commit d688ef0

Please sign in to comment.