mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
removed dupe code
This commit is contained in:
@@ -91,7 +91,7 @@ define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll']
|
|||||||
|
|
||||||
$('.loading-indicator').removeClass('hidden');
|
$('.loading-indicator').removeClass('hidden');
|
||||||
|
|
||||||
infinitescroll.loadMore('user.loadMoreRecentPosts', {
|
infinitescroll.loadMore('posts.loadMoreUserPosts', {
|
||||||
after: $('.user-recent-posts').attr('data-nextstart'),
|
after: $('.user-recent-posts').attr('data-nextstart'),
|
||||||
uid: theirid
|
uid: theirid
|
||||||
}, function(data, done) {
|
}, function(data, done) {
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ accountsController.getAccount = function(req, res, next) {
|
|||||||
user.isFollowing(callerUID, userData.theirid, next);
|
user.isFollowing(callerUID, userData.theirid, next);
|
||||||
},
|
},
|
||||||
posts: function(next) {
|
posts: function(next) {
|
||||||
posts.getPostsByUid(callerUID, userData.theirid, 0, 9, next);
|
posts.getPostsFromSet('uid:' + userData.theirid + ':posts', callerUID, 0, 9, next);
|
||||||
},
|
},
|
||||||
signature: function(next) {
|
signature: function(next) {
|
||||||
postTools.parseSignature(userData, callerUID, next);
|
postTools.parseSignature(userData, callerUID, next);
|
||||||
@@ -230,7 +230,7 @@ accountsController.getFavourites = function(req, res, next) {
|
|||||||
return helpers.notAllowed(req, res);
|
return helpers.notAllowed(req, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
posts.getFavourites(userData.uid, 0, 9, function (err, favourites) {
|
posts.getPostsFromSet('uid:' + userData.uid + ':favourites', callerUID, 0, 9, function(err, favourites) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
@@ -254,8 +254,7 @@ accountsController.getPosts = function(req, res, next) {
|
|||||||
if (!userData) {
|
if (!userData) {
|
||||||
return helpers.notFound(res);
|
return helpers.notFound(res);
|
||||||
}
|
}
|
||||||
|
posts.getPostsFromSet('uid:' + userData.uid + ':posts', callerUID, 0, 19, function(err, userPosts) {
|
||||||
posts.getPostsByUid(callerUID, userData.uid, 0, 19, function (err, userPosts) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,35 +106,20 @@ module.exports = function(Posts) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Posts.getPostsByUid = function(callerUid, uid, start, end, callback) {
|
Posts.getPostsFromSet = function(set, uid, start, end, callback) {
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function(next) {
|
function(next) {
|
||||||
user.getPostIds(uid, start, end, next);
|
db.getSortedSetRevRange(set, start, end, next);
|
||||||
},
|
},
|
||||||
function(pids, next) {
|
function(pids, next) {
|
||||||
privileges.posts.filter('read', pids, callerUid, next);
|
privileges.posts.filter('read', pids, uid, next);
|
||||||
},
|
},
|
||||||
function(pids, next) {
|
function(pids, next) {
|
||||||
Posts.getPostSummaryByPids(pids, callerUid, {stripTags: false}, next);
|
Posts.getPostSummaryByPids(pids, uid, {stripTags: false}, next);
|
||||||
},
|
},
|
||||||
function(posts, next) {
|
function(posts, next) {
|
||||||
next(null, {posts: posts, nextStart: end + 1});
|
next(null, {posts: posts, nextStart: end + 1});
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Posts.getFavourites = function(uid, start, end, callback) {
|
|
||||||
async.waterfall([
|
|
||||||
function(next) {
|
|
||||||
db.getSortedSetRevRange('uid:' + uid + ':favourites', start, end, next);
|
|
||||||
},
|
|
||||||
function(pids, next) {
|
|
||||||
Posts.getPostSummaryByPids(pids, uid, {stripTags: false}, next);
|
|
||||||
},
|
|
||||||
function(posts, next) {
|
|
||||||
callback(null, {posts: posts, nextStart: end + 1});
|
|
||||||
}
|
|
||||||
], callback);
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ var async = require('async'),
|
|||||||
groups = require('../groups'),
|
groups = require('../groups'),
|
||||||
user = require('../user'),
|
user = require('../user'),
|
||||||
websockets = require('./index'),
|
websockets = require('./index'),
|
||||||
|
utils = require('../../public/src/utils'),
|
||||||
|
|
||||||
SocketPosts = {};
|
SocketPosts = {};
|
||||||
|
|
||||||
@@ -375,18 +376,18 @@ SocketPosts.loadMoreFavourites = function(socket, data, callback) {
|
|||||||
var start = parseInt(data.after, 10),
|
var start = parseInt(data.after, 10),
|
||||||
end = start + 9;
|
end = start + 9;
|
||||||
|
|
||||||
posts.getFavourites(socket.uid, start, end, callback);
|
posts.getPostsFromSet('uid:' + socket.uid + ':posts', socket.uid, start, end, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketPosts.loadMoreUserPosts = function(socket, data, callback) {
|
SocketPosts.loadMoreUserPosts = function(socket, data, callback) {
|
||||||
if(!data || !data.after || !data.uid) {
|
if(!data || !data.uid || !utils.isNumber(data.after)) {
|
||||||
return callback(new Error('[[error:invalid-data]]'));
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
var start = parseInt(data.after, 10),
|
var start = Math.max(0, parseInt(data.after, 10)),
|
||||||
end = start + 9;
|
end = start + 9;
|
||||||
|
|
||||||
posts.getPostsByUid(socket.uid, data.uid, start, end, callback);
|
posts.getPostsFromSet('uid:' + data.uid + ':posts', socket.uid, start, end, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -365,17 +365,6 @@ SocketUser.loadMore = function(socket, data, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketUser.loadMoreRecentPosts = function(socket, data, callback) {
|
|
||||||
if(!data || !data.uid || !utils.isNumber(data.after)) {
|
|
||||||
return callback(new Error('[[error:invalid-data]]'));
|
|
||||||
}
|
|
||||||
|
|
||||||
var start = Math.max(0, parseInt(data.after, 10)),
|
|
||||||
end = start + 9;
|
|
||||||
|
|
||||||
posts.getPostsByUid(socket.uid, data.uid, start, end, callback);
|
|
||||||
};
|
|
||||||
|
|
||||||
SocketUser.setStatus = function(socket, status, callback) {
|
SocketUser.setStatus = function(socket, status, callback) {
|
||||||
if (!socket.uid) {
|
if (!socket.uid) {
|
||||||
return callback(new Error('[[invalid-uid]]'));
|
return callback(new Error('[[invalid-uid]]'));
|
||||||
|
|||||||
Reference in New Issue
Block a user