mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
notification fixes
made post notifications unique per post so they dont overwrite other types.
This commit is contained in:
@@ -170,7 +170,32 @@ module.exports = function(db, module) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.sortedSetsCard = function(keys, callback) {
|
module.sortedSetsCard = function(keys, callback) {
|
||||||
async.map(keys, module.sortedSetCard, callback);
|
var pipeline = [
|
||||||
|
{ $match : { _key : { $in: keys } } } ,
|
||||||
|
{ $group: { _id: {_key: '$_key'}, count: { $sum: 1 } } },
|
||||||
|
{ $project: { _id: 1, count: '$count' } }
|
||||||
|
];
|
||||||
|
db.collection('objects').aggregate(pipeline, function(err, results) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Array.isArray(results)) {
|
||||||
|
results = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
var map = {};
|
||||||
|
results.forEach(function(item) {
|
||||||
|
if (item && item._id._key) {
|
||||||
|
map[item._id._key] = item.count;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
results = keys.map(function(key) {
|
||||||
|
return map[key] || 0;
|
||||||
|
});
|
||||||
|
callback(null, results);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.sortedSetRank = function(key, value, callback) {
|
module.sortedSetRank = function(key, value, callback) {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ var async = require('async'),
|
|||||||
|
|
||||||
if (oldNotification) {
|
if (oldNotification) {
|
||||||
if (parseInt(oldNotification.pid, 10) === parseInt(data.pid, 10) && parseInt(oldNotification.importance, 10) > parseInt(data.importance, 10)) {
|
if (parseInt(oldNotification.pid, 10) === parseInt(data.pid, 10) && parseInt(oldNotification.importance, 10) > parseInt(data.importance, 10)) {
|
||||||
return callback(null, null);
|
return callback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ SocketTopics.sendNotificationToTopicOwner = function(tid, fromuid, notification)
|
|||||||
notifications.create({
|
notifications.create({
|
||||||
bodyShort: '[[' + notification + ', ' + results.username + ']]',
|
bodyShort: '[[' + notification + ', ' + results.username + ']]',
|
||||||
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug,
|
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug,
|
||||||
nid: 'topic:' + tid + ':uid:' + fromuid,
|
nid: 'tid:' + tid + ':uid:' + fromuid,
|
||||||
from: fromuid
|
from: fromuid
|
||||||
}, function(err, notification) {
|
}, function(err, notification) {
|
||||||
if (!err && notification) {
|
if (!err && notification) {
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ SocketUser.follow = function(socket, data, callback) {
|
|||||||
notifications.create({
|
notifications.create({
|
||||||
bodyShort: '[[notifications:user_started_following_you, ' + userData.username + ']]',
|
bodyShort: '[[notifications:user_started_following_you, ' + userData.username + ']]',
|
||||||
path: nconf.get('relative_path') + '/user/' + userData.userslug,
|
path: nconf.get('relative_path') + '/user/' + userData.userslug,
|
||||||
nid: 'follow:uid:' + socket.uid,
|
nid: 'follow:' + data.uid + ':uid:' + socket.uid,
|
||||||
from: socket.uid
|
from: socket.uid
|
||||||
}, function(err, notification) {
|
}, function(err, notification) {
|
||||||
if (!err && notification) {
|
if (!err && notification) {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ module.exports = function(Topics) {
|
|||||||
bodyShort: '[[notifications:user_posted_to, ' + results.username + ', ' + results.title + ']]',
|
bodyShort: '[[notifications:user_posted_to, ' + results.username + ', ' + results.title + ']]',
|
||||||
bodyLong: results.postContent,
|
bodyLong: results.postContent,
|
||||||
pid: pid,
|
pid: pid,
|
||||||
nid: 'topic:' + tid + ':uid:' + exceptUid,
|
nid: 'tid:' + tid + ':pid:' + pid + ':uid:' + exceptUid,
|
||||||
tid: tid,
|
tid: tid,
|
||||||
from: exceptUid
|
from: exceptUid
|
||||||
}, function(err, notification) {
|
}, function(err, notification) {
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ var async = require('async'),
|
|||||||
bodyShort: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topic.title + ']]',
|
bodyShort: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topic.title + ']]',
|
||||||
bodyLong: results.postContent,
|
bodyLong: results.postContent,
|
||||||
pid: pid,
|
pid: pid,
|
||||||
nid: 'topic:' + tid + ':uid:' + uid,
|
nid: 'tid:' + tid + ':pid:' + pid + ':uid:' + uid,
|
||||||
tid: tid,
|
tid: tid,
|
||||||
from: uid
|
from: uid
|
||||||
}, function(err, notification) {
|
}, function(err, notification) {
|
||||||
|
|||||||
Reference in New Issue
Block a user