This commit is contained in:
syuilo
2018-03-28 16:39:14 +09:00
parent 7d4d9dbaa6
commit 3d5cdb8d2d
237 changed files with 1661 additions and 1354 deletions

View File

@@ -13,9 +13,9 @@ import Post from '../../../models/post';
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = $(params.post_id).id().$;
if (postIdErr) return rej('invalid post_id param');
// Get 'postId' parameter
const [postId, postIdErr] = $(params.postId).id().$;
if (postIdErr) return rej('invalid postId param');
// Get favoritee
const post = await Post.findOne({
@@ -28,8 +28,8 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// if already favorited
const exist = await Favorite.findOne({
post_id: post._id,
user_id: user._id
postId: post._id,
userId: user._id
});
if (exist !== null) {
@@ -38,9 +38,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Create favorite
await Favorite.insert({
created_at: new Date(),
post_id: post._id,
user_id: user._id
createdAt: new Date(),
postId: post._id,
userId: user._id
});
// Send response