|
|
@@ -198,10 +198,13 @@ module.exports = (crowi) => {
|
|
|
|
|
|
router.get('/likeInfo', async(req, res) => {
|
|
|
const pageId = req.query._id;
|
|
|
+ const userId = req.user._id;
|
|
|
const likeInfo = {};
|
|
|
try {
|
|
|
+ const page = await Page.findById(pageId);
|
|
|
likeInfo.users = await Page.findById(pageId).populate('liker', User.USER_PUBLIC_FIELDS);
|
|
|
- likeInfo.sumOfLikers = likeInfo.users.liker.length;
|
|
|
+ likeInfo.sumOfLikers = page.liker.length;
|
|
|
+ likeInfo.isLiked = page.liker.includes(userId);
|
|
|
|
|
|
return res.apiv3({ likeInfo });
|
|
|
}
|