mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-17 22:10:23 +01:00
closes #831, user profile changes
This commit is contained in:
@@ -72,6 +72,7 @@ var fs = require('fs'),
|
||||
createRoute('/:userslug/following', '/following', 'following');
|
||||
createRoute('/:userslug/followers', '/followers', 'followers');
|
||||
createRoute('/:userslug/favourites', '/favourites', 'favourites');
|
||||
createRoute('/:userslug/posts', '/posts', 'accountposts');
|
||||
|
||||
app.get('/:userslug/edit', function (req, res) {
|
||||
|
||||
@@ -363,6 +364,42 @@ var fs = require('fs'),
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/api/user/:userslug/posts', function (req, res, next) {
|
||||
var callerUID = req.user ? req.user.uid : '0';
|
||||
|
||||
user.getUidByUserslug(req.params.userslug, function (err, uid) {
|
||||
if (!uid) {
|
||||
res.json(404, {
|
||||
error: 'User not found!'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
user.getUserFields(uid, ['username', 'userslug'], function (err, userData) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (userData) {
|
||||
posts.getPostsByUid(callerUID, uid, 0, 19, function (err, userPosts) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
userData.uid = uid;
|
||||
userData.posts = userPosts.posts;
|
||||
userData.nextStart = userPosts.nextStart;
|
||||
|
||||
res.json(userData);
|
||||
});
|
||||
} else {
|
||||
res.json(404, {
|
||||
error: 'User not found!'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/api/user/:userslug', function (req, res, next) {
|
||||
var callerUID = req.user ? req.user.uid : '0';
|
||||
|
||||
@@ -375,13 +412,13 @@ var fs = require('fs'),
|
||||
|
||||
user.isFollowing(callerUID, userData.theirid, function (isFollowing) {
|
||||
|
||||
posts.getPostsByUid(callerUID, userData.theirid, 0, 9, function (err, posts) {
|
||||
posts.getPostsByUid(callerUID, userData.theirid, 0, 9, function (err, userPosts) {
|
||||
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
userData.posts = posts.filter(function (p) {
|
||||
userData.posts = userPosts.posts.filter(function (p) {
|
||||
return p && parseInt(p.deleted, 10) !== 1;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user