v1.18.x
barisusakli 11 years ago
parent 1664d179b9
commit 980cf2ccf9

@ -663,20 +663,26 @@ define(['forum/pagination', 'forum/topic/threadTools', 'forum/topic/postTools'],
}, duration !== undefined ? duration : 400, function() {
scrollingToPost = false;
updateHeader();
if (highlight) {
scrollTo.parent().find('.topic-item').addClass('highlight');
setTimeout(function() {
scrollTo.parent().find('.topic-item').removeClass('highlight');
}, 5000);
}
highlightPost();
});
}
function highlightPost() {
if (highlight) {
scrollTo.parent().find('.topic-item').addClass('highlight');
setTimeout(function() {
scrollTo.parent().find('.topic-item').removeClass('highlight');
}, 5000);
}
}
if (tid && scrollTo.length) {
if($('#post-container li.post-row[data-pid="' + pid + '"]').attr('data-index') !== '0') {
animateScroll();
} else {
updateHeader();
highlightPost();
}
}
}

@ -80,6 +80,7 @@ SocketPosts.reply = function(socket, data, callback) {
SocketPosts.upvote = function(socket, data) {
favouriteCommand('upvote', socket, data);
sendNotificationToPostOwner(data, socket.uid, 'has upvoted your post');
};
SocketPosts.downvote = function(socket, data) {
@ -92,6 +93,7 @@ SocketPosts.unvote = function(socket, data) {
SocketPosts.favourite = function(socket, data) {
favouriteCommand('favourite', socket, data);
sendNotificationToPostOwner(data, socket.uid, 'has favourited your post');
};
SocketPosts.unfavourite = function(socket, data) {
@ -104,6 +106,37 @@ function favouriteCommand(command, socket, data) {
}
}
function sendNotificationToPostOwner(data, uid, message) {
if(data && data.pid && uid) {
posts.getPostFields(data.pid, ['tid', 'uid'], function(err, postData) {
if (err) {
return;
}
async.parallel({
username: function(next) {
user.getUserField(uid, 'username', next);
},
slug: function(next) {
topics.getTopicField(postData.tid, 'slug', next);
}
}, function(err, results) {
if (err) {
return;
}
notifications.create({
text: '<strong>' + results.username + '</strong> ' + message,
path: nconf.get('relative_path') + '/topic/' + results.slug + '#' + data.pid,
uniqueId: 'post:' + data.pid,
from: uid
}, function(nid) {
notifications.push(nid, [postData.uid]);
});
});
});
}
}
SocketPosts.getRawPost = function(socket, pid, callback) {
posts.getPostFields(pid, ['content', 'deleted'], function(err, data) {
if(err) {
@ -248,7 +281,7 @@ SocketPosts.flag = function(socket, pid, callback) {
user.getUserField(socket.uid, 'username', next);
},
function(username, next) {
message = username + ' flagged a post.';
message = '<strong>' + username + '</strong> flagged a post.';
posts.getPostField(pid, 'tid', next);
},
function(tid, next) {
@ -306,6 +339,6 @@ SocketPosts.getRecentPosts = function(socket, data, callback) {
SocketPosts.getCategory = function(socket, pid, callback) {
posts.getCidByPid(pid, callback);
}
};
module.exports = SocketPosts;
Loading…
Cancel
Save