final pass #1720, closed #1720

v1.18.x
Julian Lam 11 years ago
parent d257632878
commit c41bb05711

@ -25,7 +25,7 @@ define('notifications', ['sounds'], function(sound) {
image = '';
}
return '<li class="' + (notification.readClass || '') + '"><a href="' + (notification.path || '#') + '">' + image + '<span class="pull-right relTime">' + utils.relativeTime(notification.datetime, true) + '</span><span class="text">' + notification.text + '</span></a></li>';
return '<li class="' + (notification.readClass || '') + '"><a href="' + (notification.path || '#') + '">' + image + '<span class="pull-right relTime">' + utils.relativeTime(notification.datetime, true) + '</span><span class="text">' + notification.bodyShort + '</span></a></li>';
}
var x, html = '';

@ -32,10 +32,18 @@ var async = require('async'),
if (exists) {
db.sortedSetRank('uid:' + uid + ':notifications:read', nid, function(err, rank) {
db.getObjectFields('notifications:' + nid, ['nid', 'from', 'text', 'image', 'importance', 'score', 'path', 'datetime', 'uniqueId'], function(err, notification) {
db.getObject('notifications:' + nid, function(err, notification) {
notification.read = rank !== null ? true:false;
notification.text = validator.escape(notification.text);
// Backwards compatibility for old notification schema
if (notification.hasOwnProperty('text')) {
notification.bodyShort = notification.text;
notification.bodyLong = '';
notification.text = validator.escape(notification.text);
}
notification.bodyShort = validator.escape(notification.bodyShort);
notification.bodyLong = validator.escape(notification.bodyLong);
if (notification.from && !notification.image) {
User.getUserField(notification.from, 'picture', function(err, picture) {
@ -85,10 +93,8 @@ var async = require('async'),
// Add default values to data Object if not already set
var defaults = {
body: {
short: '',
long: ''
},
bodyShort: '',
bodyLong: '',
path: '',
importance: 5,
datetime: Date.now(),
@ -101,13 +107,11 @@ var async = require('async'),
}
}
// Backwards compatibility for old notification syntax
// Backwards compatibility for old notification schema
// Remove this block for NodeBB v0.6.0
if (data.hasOwnProperty('text') && !data.hasOwnProperty('body')) {
data.body = {
short: data.text,
long: ''
};
if (data.hasOwnProperty('text')) {
data.bodyShort = data.text;
data.bodyLong = '';
delete data.text;
}
@ -117,6 +121,8 @@ var async = require('async'),
db.setObject('notifications:' + nid, data, function(err, status) {
if (!err) {
callback(nid);
} else {
winston.error('[notifications.create] ' + err.message);
}
});
});

@ -54,10 +54,7 @@ module.exports = function(app, middleware, controllers) {
});
app.get('/test', function(req, res) {
var a = require('../groups');
a.getLatestMemberPosts('mcg', 5, function() {
res.json(arguments);
});
res.redirect('404');
});
});
};

@ -208,10 +208,8 @@ function sendChatNotification(fromuid, touid, username, message) {
if (!module.parent.exports.isUserOnline(touid)) {
var notifText = '[[notifications:new_message_from, ' + username + ']]';
notifications.create({
body: {
short: notifText,
long: message
},
bodyShort: notifText,
bodyLong: message,
path: 'javascript:app.openChat(&apos;' + username + '&apos;, ' + fromuid + ');',
uniqueId: 'notification_' + fromuid + '_' + touid,
from: fromuid

@ -115,10 +115,8 @@ function sendNotificationToPostOwner(data, uid, notification) {
}
notifications.create({
body: {
short: '[[' + notification + ', ' + results.username + ']]',
long: results.topicData.content
},
bodyShort: '[[' + notification + ', ' + results.username + ']]',
bodyLong: results.topicData.content,
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug + '/' + results.index,
uniqueId: 'post:' + data.pid,
from: uid
@ -309,10 +307,8 @@ SocketPosts.flag = function(socket, pid, callback) {
},
function(adminGroup, next) {
notifications.create({
body: {
short: message,
long: post.content
},
bodyShort: message,
bodyLong: post.content,
path: path,
uniqueId: 'post_flag:' + pid,
from: socket.uid

@ -34,10 +34,8 @@ module.exports = function(Topics) {
}
notifications.create({
body: {
short: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topicData.title + ']]',
long: results.postContent
},
bodyShort: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topicData.title + ']]',
bodyLong: results.postContent,
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug + '/' + results.postIndex,
uniqueId: 'topic:' + tid,
from: exceptUid

@ -163,10 +163,8 @@ module.exports = function(User) {
if (userNameChanged) {
notifications.create({
body: {
short: '[[user:username_taken_workaround, ' + userData.username + ']]',
long: ''
},
bodyShort: '[[user:username_taken_workaround, ' + userData.username + ']]',
bodyLong: '',
image: 'brand:logo',
datetime: Date.now()
}, function(nid) {

@ -163,10 +163,8 @@ var async = require('async'),
}
notifications.create({
body: {
short: '[[notifications:user_made_post, ' + results.username + ']]',
long: results.postContent
},
bodyShort: '[[notifications:user_made_post, ' + results.username + ']]',
bodyLong: results.postContent,
path: nconf.get('relative_path') + '/topic/' + results.slug + '/' + results.postIndex,
uniqueId: 'topic:' + tid,
from: uid

Loading…
Cancel
Save