Skip to content

Commit

Permalink
更改AT评论判断方式,重新增加rid字段
Browse files Browse the repository at this point in the history
  • Loading branch information
ZvonimirSun committed Mar 25, 2018
1 parent 4a3cef5 commit 813dbc3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ AV.Cloud.afterSave('Comment', function (request) {
// 发送博主通知邮件
mail.notice(currentComment);
// AT评论通知
let rid = currentComment.get('rid');
if (!rid) {
// 获取评论内容
var comm = currentComment.get('comment');
// 从评论内容中提取出a标签的href属性值
var h = comm.match(/<a.*?href?\s*=\s*[\'|\"]+?(.*?)[\'|\"]+?/i);
if (!h) {
console.log('没有@任何人,结束!');
return;
}
// 替换掉#号,即为rid。
let rid = h[1].replace(/#/,"");
// 将rid存入数据库,以供管理页面使用。
currentComment.set('rid', rid);
let query = new AV.Query('Comment');
query.get(rid).then(function (parentComment) {
mail.send(currentComment, parentComment);
Expand Down

0 comments on commit 813dbc3

Please sign in to comment.