mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
added topic titles to notifs
upvote, favourite and flag has topic titles now
This commit is contained in:
@@ -12,11 +12,11 @@
|
|||||||
"you_have_unread_notifications": "You have unread notifications.",
|
"you_have_unread_notifications": "You have unread notifications.",
|
||||||
|
|
||||||
"new_message_from": "New message from <strong>%1</strong>",
|
"new_message_from": "New message from <strong>%1</strong>",
|
||||||
"upvoted_your_post": "<strong>%1</strong> has upvoted your post.",
|
"upvoted_your_post_in": "<strong>%1</strong> has upvoted your post in <strong>%2</strong>.",
|
||||||
"moved_your_post": "<strong>%1<strong> has moved your post.",
|
"moved_your_post": "<strong>%1<strong> has moved your post.",
|
||||||
"moved_your_topic": "<strong>%1<strong> has moved your topic.",
|
"moved_your_topic": "<strong>%1<strong> has moved your topic.",
|
||||||
"favourited_your_post": "<strong>%1</strong> has favourited your post.",
|
"favourited_your_post_in": "<strong>%1</strong> has favourited your post in <strong>%2</strong>.",
|
||||||
"user_flagged_post": "<strong>%1</strong> flagged a post.",
|
"user_flagged_post_in": "<strong>%1</strong> flagged a post in <strong>%2</strong>",
|
||||||
"user_posted_to" : "<strong>%1</strong> has posted a reply to: <strong>%2</strong>",
|
"user_posted_to" : "<strong>%1</strong> has posted a reply to: <strong>%2</strong>",
|
||||||
"user_mentioned_you_in": "<strong>%1</strong> mentioned you in <strong>%2</strong>",
|
"user_mentioned_you_in": "<strong>%1</strong> mentioned you in <strong>%2</strong>",
|
||||||
"user_started_following_you": "<strong>%1</strong> started following you.",
|
"user_started_following_you": "<strong>%1</strong> started following you.",
|
||||||
|
|||||||
@@ -65,7 +65,9 @@ function getUsers(set, res, next) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
data = data.filter(function(user) {
|
||||||
|
return user && parseInt(user.uid, 10);
|
||||||
|
});
|
||||||
db.sortedSetCard(set, function(err, count) {
|
db.sortedSetCard(set, function(err, count) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ SocketPosts.upvote = function(socket, data, callback) {
|
|||||||
return callback(new Error('[[error:invalid-data]]'));
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
}
|
}
|
||||||
favouriteCommand('upvote', 'voted', socket, data, callback);
|
favouriteCommand('upvote', 'voted', socket, data, callback);
|
||||||
SocketPosts.sendNotificationToPostOwner(data.pid, socket.uid, 'notifications:upvoted_your_post');
|
SocketPosts.sendNotificationToPostOwner(data.pid, socket.uid, 'notifications:upvoted_your_post_in');
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketPosts.downvote = function(socket, data, callback) {
|
SocketPosts.downvote = function(socket, data, callback) {
|
||||||
@@ -79,7 +79,7 @@ SocketPosts.favourite = function(socket, data, callback) {
|
|||||||
return callback(new Error('[[error:invalid-data]]'));
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
}
|
}
|
||||||
favouriteCommand('favourite', 'favourited', socket, data, callback);
|
favouriteCommand('favourite', 'favourited', socket, data, callback);
|
||||||
SocketPosts.sendNotificationToPostOwner(data.pid, socket.uid, 'notifications:favourited_your_post');
|
SocketPosts.sendNotificationToPostOwner(data.pid, socket.uid, 'notifications:favourited_your_post_in');
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketPosts.unfavourite = function(socket, data, callback) {
|
SocketPosts.unfavourite = function(socket, data, callback) {
|
||||||
@@ -107,7 +107,7 @@ SocketPosts.sendNotificationToPostOwner = function(pid, fromuid, notification) {
|
|||||||
if(!pid || !fromuid) {
|
if(!pid || !fromuid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
posts.getPostFields(pid, ['tid', 'uid'], function(err, postData) {
|
posts.getPostFields(pid, ['tid', 'uid', 'content'], function(err, postData) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -118,21 +118,15 @@ SocketPosts.sendNotificationToPostOwner = function(pid, fromuid, notification) {
|
|||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
username: async.apply(user.getUserField, fromuid, 'username'),
|
username: async.apply(user.getUserField, fromuid, 'username'),
|
||||||
postContent: function(next) {
|
topicTitle: async.apply(topics.getTopicField, postData.tid, 'title'),
|
||||||
async.waterfall([
|
postContent: async.apply(postTools.parse, postData.content)
|
||||||
async.apply(posts.getPostField, pid, 'content'),
|
|
||||||
function(content, next) {
|
|
||||||
postTools.parse(content, next);
|
|
||||||
}
|
|
||||||
], next);
|
|
||||||
}
|
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
notifications.create({
|
notifications.create({
|
||||||
bodyShort: '[[' + notification + ', ' + results.username + ']]',
|
bodyShort: '[[' + notification + ', ' + results.username + ', ' + results.topicTitle + ']]',
|
||||||
bodyLong: results.postContent,
|
bodyLong: results.postContent,
|
||||||
pid: pid,
|
pid: pid,
|
||||||
nid: 'post:' + pid + ':uid:' + fromuid,
|
nid: 'post:' + pid + ':uid:' + fromuid,
|
||||||
@@ -279,6 +273,7 @@ SocketPosts.flag = function(socket, pid, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var message = '',
|
var message = '',
|
||||||
|
userName = '',
|
||||||
post;
|
post;
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
@@ -289,20 +284,20 @@ SocketPosts.flag = function(socket, pid, callback) {
|
|||||||
if (parseInt(userData.reputation, 10) < parseInt(meta.config['privileges:flag'] || 1, 10)) {
|
if (parseInt(userData.reputation, 10) < parseInt(meta.config['privileges:flag'] || 1, 10)) {
|
||||||
return next(new Error('[[error:not-enough-reputation-to-flag]]'));
|
return next(new Error('[[error:not-enough-reputation-to-flag]]'));
|
||||||
}
|
}
|
||||||
message = '[[notifications:user_flagged_post, ' + userData.username + ']]';
|
userName = userData.username;
|
||||||
|
|
||||||
posts.getPostFields(pid, ['tid', 'uid', 'content'], next);
|
posts.getPostFields(pid, ['tid', 'uid', 'content'], next);
|
||||||
},
|
},
|
||||||
function(postData, next) {
|
|
||||||
postTools.parse(postData.content, function(err, parsed) {
|
|
||||||
if (err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
postData.content = parsed;
|
|
||||||
next(null, postData);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
function(postData, next) {
|
function(postData, next) {
|
||||||
post = postData;
|
post = postData;
|
||||||
|
topics.getTopicField(postData.tid, 'title', next);
|
||||||
|
},
|
||||||
|
function(topicTitle, next) {
|
||||||
|
message = '[[notifications:user_flagged_post_in, ' + userName + ', ' + topicTitle + ']]';
|
||||||
|
postTools.parse(post.content, next);
|
||||||
|
},
|
||||||
|
function(postContent, next) {
|
||||||
|
post.content = postContent;
|
||||||
groups.get('administrators', {}, next);
|
groups.get('administrators', {}, next);
|
||||||
},
|
},
|
||||||
function(adminGroup, next) {
|
function(adminGroup, next) {
|
||||||
|
|||||||
Reference in New Issue
Block a user