v1.18.x
barisusakli 10 years ago
parent c2fb1eaabf
commit 6802bf7ce9

@ -250,7 +250,6 @@ module.exports = function(Topics) {
}, },
function(results, next) { function(results, next) {
postData.user = results.userInfo[0]; postData.user = results.userInfo[0];
results.topicInfo.title = validator.escape(results.topicInfo.title);
postData.topic = results.topicInfo; postData.topic = results.topicInfo;
postData.content = results.content; postData.content = results.content;
@ -266,9 +265,10 @@ module.exports = function(Topics) {
postData.relativeTime = utils.toISOString(postData.timestamp); postData.relativeTime = utils.toISOString(postData.timestamp);
if (parseInt(uid, 10)) { if (parseInt(uid, 10)) {
Topics.notifyFollowers(postData.topic, postData, uid); Topics.notifyFollowers(postData, uid);
} }
postData.topic.title = validator.escape(postData.topic.title);
next(null, postData); next(null, postData);
} }
], callback); ], callback);

@ -3,6 +3,7 @@
var async = require('async'), var async = require('async'),
nconf = require('nconf'), nconf = require('nconf'),
S = require('string'),
db = require('../database'), db = require('../database'),
user = require('../user'), user = require('../user'),
@ -21,8 +22,8 @@ module.exports = function(Topics) {
db.getSetMembers('tid:' + tid + ':followers', callback); db.getSetMembers('tid:' + tid + ':followers', callback);
}; };
Topics.notifyFollowers = function(topicData, postData, exceptUid) { Topics.notifyFollowers = function(postData, exceptUid) {
Topics.getFollowers(topicData.tid, function(err, followers) { Topics.getFollowers(postData.topic.tid, function(err, followers) {
if (err || !Array.isArray(followers) || !followers.length) { if (err || !Array.isArray(followers) || !followers.length) {
return; return;
} }
@ -36,12 +37,17 @@ module.exports = function(Topics) {
return; return;
} }
var title = postData.topic.title;
if (title) {
title = S(title).decodeHTMLEntities().s;
}
notifications.create({ notifications.create({
bodyShort: '[[notifications:user_posted_to, ' + postData.user.username + ', ' + topicData.title + ']]', bodyShort: '[[notifications:user_posted_to, ' + postData.user.username + ', ' + title + ']]',
bodyLong: postData.content, bodyLong: postData.content,
pid: postData.pid, pid: postData.pid,
nid: 'tid:' + topicData.tid + ':pid:' + postData.pid + ':uid:' + exceptUid, nid: 'tid:' + postData.topic.tid + ':pid:' + postData.pid + ':uid:' + exceptUid,
tid: topicData.tid, tid: postData.topic.tid,
from: exceptUid from: exceptUid
}, function(err, notification) { }, function(err, notification) {
if (!err && notification) { if (!err && notification) {

@ -4,6 +4,7 @@
var async = require('async'), var async = require('async'),
nconf = require('nconf'), nconf = require('nconf'),
winston = require('winston'), winston = require('winston'),
S = require('string'),
user = require('../user'), user = require('../user'),
utils = require('../../public/src/utils'), utils = require('../../public/src/utils'),
@ -240,8 +241,13 @@ var async = require('async'),
return; return;
} }
var title = topicData.title;
if (title) {
title = S(title).decodeHTMLEntities().s;
}
notifications.create({ notifications.create({
bodyShort: '[[notifications:user_posted_topic, ' + postData.user.username + ', ' + topicData.title + ']]', bodyShort: '[[notifications:user_posted_topic, ' + postData.user.username + ', ' + title + ']]',
bodyLong: postData.content, bodyLong: postData.content,
pid: postData.pid, pid: postData.pid,
nid: 'tid:' + postData.tid + ':pid:' + postData.pid + ':uid:' + uid, nid: 'tid:' + postData.tid + ':pid:' + postData.pid + ':uid:' + uid,

Loading…
Cancel
Save