privilege fix for single category check

This commit is contained in:
barisusakli
2014-08-02 19:45:13 -04:00
parent e7700a3fde
commit e420ee5fb6
7 changed files with 62 additions and 76 deletions

View File

@@ -24,53 +24,47 @@ var async = require('async'),
};
Notifications.get = function(nid, callback) {
db.exists('notifications:' + nid, function(err, exists) {
db.getObject('notifications:' + nid, function(err, notification) {
if (err) {
winston.error('[notifications.get] Could not retrieve nid ' + nid + ': ' + err.message);
return callback(err);
}
if (!exists) {
if (!notification) {
winston.info('[notifications.get] Could not retrieve nid ' + nid);
return callback(null, null);
}
db.getObject('notifications:' + nid, function(err, notification) {
if (err) {
return callback(err);
}
// Backwards compatibility for old notification schema
// Remove this block when NodeBB v0.6.0 is released.
if (notification.hasOwnProperty('text')) {
notification.bodyShort = notification.text;
notification.bodyLong = '';
notification.text = S(notification.text).escapeHTML().s;
}
// Backwards compatibility for old notification schema
// Remove this block when NodeBB v0.6.0 is released.
if (notification.hasOwnProperty('text')) {
notification.bodyShort = notification.text;
notification.bodyLong = '';
notification.text = S(notification.text).escapeHTML().s;
}
notification.bodyShort = S(notification.bodyShort).escapeHTML().s;
notification.bodyLong = S(notification.bodyLong).escapeHTML().s;
notification.bodyShort = S(notification.bodyShort).escapeHTML().s;
notification.bodyLong = S(notification.bodyLong).escapeHTML().s;
if (notification.from && !notification.image) {
User.getUserField(notification.from, 'picture', function(err, picture) {
if (err) {
return callback(err);
}
notification.image = picture;
callback(null, notification);
});
return;
} else if (notification.image) {
switch(notification.image) {
case 'brand:logo':
notification.image = meta.config['brand:logo'] || nconf.get('relative_path') + '/logo.png';
break;
if (notification.from && !notification.image) {
User.getUserField(notification.from, 'picture', function(err, picture) {
if (err) {
return callback(err);
}
return callback(null, notification);
notification.image = picture;
callback(null, notification);
});
return;
} else if (notification.image) {
switch(notification.image) {
case 'brand:logo':
notification.image = meta.config['brand:logo'] || nconf.get('relative_path') + '/logo.png';
break;
}
callback(null, notification);
});
return callback(null, notification);
}
callback(null, notification);
});
};
@@ -207,18 +201,13 @@ var async = require('async'),
}
Notifications.pushGroup = function(nid, groupName, callback) {
if (!callback) {
callback = function() {};
}
callback = callback || function() {};
groups.get(groupName, {}, function(err, groupObj) {
if (!err && groupObj) {
if (groupObj.memberCount > 0) {
Notifications.push(nid, groupObj.members, callback);
}
} else {
callback(err);
if (err || !groupObj || !Array.isArray(groupObj.members) || !groupObj.members.length) {
return callback(err);
}
Notifications.push(nid, groupObj.members, callback);
});
};
@@ -229,7 +218,7 @@ var async = require('async'),
return callback();
}
Notifications.get(nid, function(err, notificationData) {
db.getObjectFields('notifications:' + nid, ['uniqueId', 'datetime'], function(err, notificationData) {
if (err || !notificationData) {
return callback(err);
}