mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
closes #1950
This commit is contained in:
@@ -241,37 +241,18 @@ SocketPosts.getPrivileges = function(socket, pid, callback) {
|
||||
};
|
||||
|
||||
SocketPosts.getFavouritedUsers = function(socket, pid, callback) {
|
||||
|
||||
favourites.getFavouritedUidsByPids([pid], function(err, data) {
|
||||
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if(!Array.isArray(data) || !data.length) {
|
||||
callback(null, "");
|
||||
callback(null, []);
|
||||
}
|
||||
|
||||
var max = 5; //hardcoded
|
||||
var finalText = "";
|
||||
|
||||
var pid_uids = data[0];
|
||||
var rest_amount = 0;
|
||||
|
||||
if (pid_uids.length > max) {
|
||||
rest_amount = pid_uids.length - max;
|
||||
pid_uids = pid_uids.slice(0, max);
|
||||
}
|
||||
|
||||
user.getUsernamesByUids(pid_uids, function(err, usernames) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
finalText = usernames.join(', ') + (rest_amount > 0 ?
|
||||
(" and " + rest_amount + (rest_amount > 1 ? " others" : " other")) : "");
|
||||
callback(null, finalText);
|
||||
});
|
||||
user.getUsernamesByUids(pid_uids, callback);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user