mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 10:06:13 +01:00
@@ -25,7 +25,7 @@ define('notifications', ['sounds'], function(sound) {
|
|||||||
image = '';
|
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 = '';
|
var x, html = '';
|
||||||
|
|||||||
@@ -32,10 +32,18 @@ var async = require('async'),
|
|||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
db.sortedSetRank('uid:' + uid + ':notifications:read', nid, function(err, rank) {
|
db.sortedSetRank('uid:' + uid + ':notifications:read', nid, function(err, rank) {
|
||||||
|
db.getObject('notifications:' + nid, function(err, notification) {
|
||||||
db.getObjectFields('notifications:' + nid, ['nid', 'from', 'text', 'image', 'importance', 'score', 'path', 'datetime', 'uniqueId'], function(err, notification) {
|
|
||||||
notification.read = rank !== null ? true:false;
|
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) {
|
if (notification.from && !notification.image) {
|
||||||
User.getUserField(notification.from, 'picture', function(err, picture) {
|
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
|
// Add default values to data Object if not already set
|
||||||
var defaults = {
|
var defaults = {
|
||||||
body: {
|
bodyShort: '',
|
||||||
short: '',
|
bodyLong: '',
|
||||||
long: ''
|
|
||||||
},
|
|
||||||
path: '',
|
path: '',
|
||||||
importance: 5,
|
importance: 5,
|
||||||
datetime: Date.now(),
|
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
|
// Remove this block for NodeBB v0.6.0
|
||||||
if (data.hasOwnProperty('text') && !data.hasOwnProperty('body')) {
|
if (data.hasOwnProperty('text')) {
|
||||||
data.body = {
|
data.bodyShort = data.text;
|
||||||
short: data.text,
|
data.bodyLong = '';
|
||||||
long: ''
|
|
||||||
};
|
|
||||||
delete data.text;
|
delete data.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +121,8 @@ var async = require('async'),
|
|||||||
db.setObject('notifications:' + nid, data, function(err, status) {
|
db.setObject('notifications:' + nid, data, function(err, status) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
callback(nid);
|
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) {
|
app.get('/test', function(req, res) {
|
||||||
var a = require('../groups');
|
res.redirect('404');
|
||||||
a.getLatestMemberPosts('mcg', 5, function() {
|
|
||||||
res.json(arguments);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -208,10 +208,8 @@ function sendChatNotification(fromuid, touid, username, message) {
|
|||||||
if (!module.parent.exports.isUserOnline(touid)) {
|
if (!module.parent.exports.isUserOnline(touid)) {
|
||||||
var notifText = '[[notifications:new_message_from, ' + username + ']]';
|
var notifText = '[[notifications:new_message_from, ' + username + ']]';
|
||||||
notifications.create({
|
notifications.create({
|
||||||
body: {
|
bodyShort: notifText,
|
||||||
short: notifText,
|
bodyLong: message,
|
||||||
long: message
|
|
||||||
},
|
|
||||||
path: 'javascript:app.openChat('' + username + '', ' + fromuid + ');',
|
path: 'javascript:app.openChat('' + username + '', ' + fromuid + ');',
|
||||||
uniqueId: 'notification_' + fromuid + '_' + touid,
|
uniqueId: 'notification_' + fromuid + '_' + touid,
|
||||||
from: fromuid
|
from: fromuid
|
||||||
|
|||||||
@@ -115,10 +115,8 @@ function sendNotificationToPostOwner(data, uid, notification) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
notifications.create({
|
notifications.create({
|
||||||
body: {
|
bodyShort: '[[' + notification + ', ' + results.username + ']]',
|
||||||
short: '[[' + notification + ', ' + results.username + ']]',
|
bodyLong: results.topicData.content,
|
||||||
long: results.topicData.content
|
|
||||||
},
|
|
||||||
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug + '/' + results.index,
|
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug + '/' + results.index,
|
||||||
uniqueId: 'post:' + data.pid,
|
uniqueId: 'post:' + data.pid,
|
||||||
from: uid
|
from: uid
|
||||||
@@ -309,10 +307,8 @@ SocketPosts.flag = function(socket, pid, callback) {
|
|||||||
},
|
},
|
||||||
function(adminGroup, next) {
|
function(adminGroup, next) {
|
||||||
notifications.create({
|
notifications.create({
|
||||||
body: {
|
bodyShort: message,
|
||||||
short: message,
|
bodyLong: post.content,
|
||||||
long: post.content
|
|
||||||
},
|
|
||||||
path: path,
|
path: path,
|
||||||
uniqueId: 'post_flag:' + pid,
|
uniqueId: 'post_flag:' + pid,
|
||||||
from: socket.uid
|
from: socket.uid
|
||||||
|
|||||||
@@ -34,10 +34,8 @@ module.exports = function(Topics) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
notifications.create({
|
notifications.create({
|
||||||
body: {
|
bodyShort: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topicData.title + ']]',
|
||||||
short: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topicData.title + ']]',
|
bodyLong: results.postContent,
|
||||||
long: results.postContent
|
|
||||||
},
|
|
||||||
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug + '/' + results.postIndex,
|
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug + '/' + results.postIndex,
|
||||||
uniqueId: 'topic:' + tid,
|
uniqueId: 'topic:' + tid,
|
||||||
from: exceptUid
|
from: exceptUid
|
||||||
|
|||||||
@@ -163,10 +163,8 @@ module.exports = function(User) {
|
|||||||
|
|
||||||
if (userNameChanged) {
|
if (userNameChanged) {
|
||||||
notifications.create({
|
notifications.create({
|
||||||
body: {
|
bodyShort: '[[user:username_taken_workaround, ' + userData.username + ']]',
|
||||||
short: '[[user:username_taken_workaround, ' + userData.username + ']]',
|
bodyLong: '',
|
||||||
long: ''
|
|
||||||
},
|
|
||||||
image: 'brand:logo',
|
image: 'brand:logo',
|
||||||
datetime: Date.now()
|
datetime: Date.now()
|
||||||
}, function(nid) {
|
}, function(nid) {
|
||||||
|
|||||||
@@ -163,10 +163,8 @@ var async = require('async'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
notifications.create({
|
notifications.create({
|
||||||
body: {
|
bodyShort: '[[notifications:user_made_post, ' + results.username + ']]',
|
||||||
short: '[[notifications:user_made_post, ' + results.username + ']]',
|
bodyLong: results.postContent,
|
||||||
long: results.postContent
|
|
||||||
},
|
|
||||||
path: nconf.get('relative_path') + '/topic/' + results.slug + '/' + results.postIndex,
|
path: nconf.get('relative_path') + '/topic/' + results.slug + '/' + results.postIndex,
|
||||||
uniqueId: 'topic:' + tid,
|
uniqueId: 'topic:' + tid,
|
||||||
from: uid
|
from: uid
|
||||||
|
|||||||
Reference in New Issue
Block a user