Skip to content

Commit

Permalink
评论邮件
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Oct 22, 2017
1 parent 18c3b2f commit 3427cb3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/default/freyja.js
Expand Up @@ -4,6 +4,7 @@
'use strict';
module.exports = {
mail: {
from: 'noreply@bangbang93.com'
from: 'noreply@bangbang93.com',
to: 'bangbang93@163.com'
}
}
17 changes: 17 additions & 0 deletions module/mail.ts
Expand Up @@ -25,3 +25,20 @@ bangbang93.forum()
html
})
}

export function comment({article}) {
const content = `
bangbang93.form()
---
文章《${article.title}》有新评论
查看链接
<https://blog.bangbang93.com/article/${article._id}>
`
const html = MarkdownHelper.render(content)
return transporter.sendMail({
from: Config.freyja.mail.from,
to: Config.freyja.mail.to,
subject: 'bangbang93.forum() 评论',
html
})
}
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -13,6 +13,7 @@
},
"dependencies": {
"@types/node": "^8.0.34",
"@types/nodemailer": "^4.2.0",
"animate.css": "^3.5.2",
"bcrypt": "^1.0.3",
"bluebird": "^3.5.0",
Expand Down
5 changes: 4 additions & 1 deletion service/comment.js
Expand Up @@ -27,12 +27,15 @@ exports.create = async function (comment, {article, reply}) {
await CommentModel.addReply(replyComment._id, newComment._id)
}

if (replyComment.publisher.email) {
if (reply && replyComment.publisher.email) {
MailModule.commentReply({
to: replyComment.publisher.email,
article: await ArticleModel.getById(article)
})
}
if (!reply) {
MailModule.comment({article: await ArticleModel.getById(article)})
}

return {
comment: newComment,
Expand Down

0 comments on commit 3427cb3

Please sign in to comment.