chore(skydive): remove jumps /feed route
Following is a CMS concept (article feed by followed authors). Applying it to jumps was a design error — no component ever called this endpoint. Removed route and associated UserService.getUserFollowed dependency from skydive.
This commit is contained in:
@@ -273,45 +273,6 @@ router.get('/allFromSkydiverIdApi', auth.required, function (req, res, next) {
|
|||||||
}).catch(next);
|
}).catch(next);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/feed', auth.required, async function (req, res, next) {
|
|
||||||
let limit = 25;
|
|
||||||
let offset = 0;
|
|
||||||
if (typeof req.query.limit !== 'undefined') {
|
|
||||||
limit = req.query.limit;
|
|
||||||
}
|
|
||||||
if (typeof req.query.offset !== 'undefined') {
|
|
||||||
offset = req.query.offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const user = await UserService.getUserById(req.payload.id);
|
|
||||||
if (!user) {
|
|
||||||
return res.status(401).json({ errors: { "Unauthorized": "autentification requise" } });
|
|
||||||
}
|
|
||||||
const following = await UserService.getUserFollowed(user);
|
|
||||||
const followingIds = following.map(u => u.id);
|
|
||||||
let query = { author: { $in: followingIds } };
|
|
||||||
const [jumps, jumpsCount] = await Promise.all([
|
|
||||||
Jump.find(query)
|
|
||||||
.skip(Number(offset))
|
|
||||||
.limit(Number(limit))
|
|
||||||
.populate('author')
|
|
||||||
.populate('files')
|
|
||||||
.populate('x2data')
|
|
||||||
.exec(),
|
|
||||||
Jump.count(query)
|
|
||||||
]);
|
|
||||||
return res.json({
|
|
||||||
jumps: jumps.map(function (jump) {
|
|
||||||
return jump.toJSONFor(null);
|
|
||||||
}),
|
|
||||||
jumpsCount: jumpsCount
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
next(err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return last jump
|
* return last jump
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user