diff --git a/core/server/services/comments/emails/new-comment-reply.hbs b/core/server/services/comments/emails/new-comment-reply.hbs index e69de29bb2..ec877044a0 100644 --- a/core/server/services/comments/emails/new-comment-reply.hbs +++ b/core/server/services/comments/emails/new-comment-reply.hbs @@ -0,0 +1,199 @@ + + + + + + 💬 New comment on {{postTitle}} + + + + + + + + + +
  +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+

Hey there,

+

Someone just replied to your comment on {{postTitle}}.

+ + + + + + + + + + +
+ + + + + +
+ + + + +
{{memberInitials}}
+
+

{{memberName}}

+

{{#if memberBio}}{{memberBio}} • {{/if}}{{replyDate}}

+
+
+ {{{replyHtml}}} +
+ + + + + + + +
+ + + + + + +
View comments
+
+
+

You can also copy & paste this URL into your browser:

+

{{postUrl}}#ghost-comments-root

+
+

This message was sent from {{siteDomain}} to {{toEmail}}

+
+

Manage your email preferences

+
+
+ + + +
+
 
+ + \ No newline at end of file diff --git a/core/server/services/comments/emails/new-comment-reply.txt.js b/core/server/services/comments/emails/new-comment-reply.txt.js new file mode 100644 index 0000000000..eb6ccd59ab --- /dev/null +++ b/core/server/services/comments/emails/new-comment-reply.txt.js @@ -0,0 +1,14 @@ +module.exports = function (data) { + return ` + Hey there, + + Someone just replied to your comment on "${data.postTitle}" + + ${data.postUrl}#comments-area + + --- + + Sent to ${data.toEmail} from ${data.siteDomain}. + You can manage your notification preferences at ${data.profileUrl}. + `; +}; diff --git a/core/server/services/comments/service.js b/core/server/services/comments/service.js index e691923126..b72e337200 100644 --- a/core/server/services/comments/service.js +++ b/core/server/services/comments/service.js @@ -106,17 +106,47 @@ class CommentsService { to, subject, html, - text, - forceTextContent: true + text }); } } - async notifyParentCommentAuthor(comment) { - const parent = await this.models.Comment.findOne({id: comment.get('parent_id')}); + async notifyParentCommentAuthor(reply) { + const parent = await this.models.Comment.findOne({id: reply.get('parent_id')}); + const parentMember = parent.related('member'); - if (parent && parent.get('status') === 'published') { + if (parent && parent.get('status') === 'published' && parentMember.get('enable_comment_notifications')) { + const to = parentMember.get('email'); + const subject = '💬 You have a new reply on one of your comments'; + const post = await this.models.Post.findOne({id: reply.get('post_id')}); + const member = await this.models.Member.findOne({id: reply.get('member_id')}); + + const templateData = { + siteTitle: this.settingsCache.get('title'), + siteUrl: this.urlUtils.getSiteUrl(), + siteDomain: this.siteDomain, + postTitle: post.get('title'), + postUrl: this.urlService.getUrlByResourceId(post.get('id'), {absolute: true}), + replyHtml: reply.get('html'), + replyDate: moment(reply.get('created_at')).tz(this.settingsCache.get('timezone')).format('D MMM YYYY'), + memberName: member.get('name'), + memberBio: member.get('bio'), + memberInitials: this.extractInitials(member.get('name')), + accentColor: this.settingsCache.get('accent_color'), + fromEmail: this.notificationFromAddress, + toEmail: to, + profileUrl: `${this.urlUtils.getSiteUrl()}#/portal/account/profile` + }; + + const {html, text} = await this.renderEmailTemplate('new-comment-reply', templateData); + + return this.sendMail({ + to, + subject, + html, + text + }); } }