mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-24 01:10:31 +01:00
Merge branch 'hashtalk' of github.com:NodeBB/NodeBB into hashtalk
This commit is contained in:
@@ -24,17 +24,46 @@ define('forum/footer', ['notifications', 'chat'], function(Notifications, Chat)
|
||||
.attr('data-content', count > 20 ? '20+' : count);
|
||||
}
|
||||
|
||||
function initUnreadTopics() {
|
||||
var unreadTopics = {};
|
||||
|
||||
function onNewPost(data) {
|
||||
if (parseInt(app.uid, 10)) {
|
||||
socket.emit('user.getUnreadCount', updateUnreadTopicCount);
|
||||
if (data && data.posts && data.posts.length) {
|
||||
var post = data.posts[0];
|
||||
|
||||
if (parseInt(post.uid, 10) !== parseInt(app.uid, 10) && !unreadTopics[post.topic.tid]) {
|
||||
increaseUnreadCount();
|
||||
markTopicsUnread(post.topic.tid);
|
||||
unreadTopics[post.topic.tid] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function increaseUnreadCount() {
|
||||
var count = parseInt($('#unread-count').attr('data-content'), 10) + 1;
|
||||
updateUnreadTopicCount(null, count);
|
||||
}
|
||||
|
||||
function markTopicsUnread(tid) {
|
||||
$('[data-tid="' + tid + '"]').addClass('unread');
|
||||
}
|
||||
|
||||
$(window).on('action:ajaxify.end', function(ev, data) {
|
||||
var tid = data.url.match(/^topic\/(\d+)/);
|
||||
|
||||
if (tid && tid[1]) {
|
||||
delete unreadTopics[tid[1]];
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('event:new_post', onNewPost);
|
||||
}
|
||||
|
||||
socket.on('event:unread.updateCount', updateUnreadTopicCount);
|
||||
socket.emit('user.getUnreadCount', updateUnreadTopicCount);
|
||||
|
||||
socket.on('event:unread.updateChatCount', updateUnreadChatCount);
|
||||
socket.emit('user.getUnreadChatCount', updateUnreadChatCount);
|
||||
|
||||
initUnreadTopics();
|
||||
});
|
||||
|
||||
@@ -136,7 +136,16 @@ accountsController.getUserByUID = function(req, res, next) {
|
||||
};
|
||||
|
||||
accountsController.getAccount = function(req, res, next) {
|
||||
var callerUID = req.user ? parseInt(req.user.uid, 10) : 0;
|
||||
var lowercaseSlug = req.params.userslug.toLowerCase(),
|
||||
callerUID = req.user ? parseInt(req.user.uid, 10) : 0;
|
||||
|
||||
if (req.params.userslug !== lowercaseSlug) {
|
||||
if (res.locals.isAPI) {
|
||||
req.params.userslug = lowercaseSlug;
|
||||
} else {
|
||||
res.redirect(nconf.get('relative_path') + '/user/' + lowercaseSlug);
|
||||
}
|
||||
}
|
||||
|
||||
getUserDataByUserSlug(req.params.userslug, callerUID, function (err, userData) {
|
||||
if(err) {
|
||||
|
||||
@@ -25,6 +25,16 @@ module.exports = function(User) {
|
||||
], callback);
|
||||
};
|
||||
|
||||
User.deleteAccount = function(uid, callback) {
|
||||
user.isAdministrator(uid, function(err, isAdmin) {
|
||||
if (err || isAdmin) {
|
||||
return callback(err || new Error('[[error:cant-ban-other-admins]]'));
|
||||
}
|
||||
|
||||
deleteAccount(uid, callback);
|
||||
});
|
||||
};
|
||||
|
||||
function deletePosts(uid, callback) {
|
||||
deleteSortedSetElements('uid:' + uid + ':posts', posts.purge, callback);
|
||||
}
|
||||
@@ -43,7 +53,7 @@ module.exports = function(User) {
|
||||
}, {alwaysStartAt: 0}, callback);
|
||||
}
|
||||
|
||||
User.deleteAccount = function(uid, callback) {
|
||||
function deleteAccount(uid, callback) {
|
||||
user.getUserFields(uid, ['username', 'userslug', 'email'], function(err, userData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -97,7 +107,7 @@ module.exports = function(User) {
|
||||
], callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function deleteUserFromFollowers(uid, callback) {
|
||||
db.getSetMembers('followers:' + uid, function(err, uids) {
|
||||
|
||||
Reference in New Issue
Block a user