1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-04 13:05:57 +02:00
This commit is contained in:
syuilo
2017-03-03 08:00:10 +09:00
parent 0926d5b6da
commit 583b64331b
6 changed files with 31 additions and 67 deletions

View File

@@ -3,9 +3,9 @@
/**
* Module dependencies
*/
import * as mongo from 'mongodb';
import Favorite from '../../models/favorite';
import Post from '../../models/post';
import it from '../../../it';
import Favorite from '../../../models/favorite';
import Post from '../../../models/post';
/**
* Favorite a post
@@ -17,10 +17,8 @@ import Post from '../../models/post';
module.exports = (params, user) =>
new Promise(async (res, rej) => {
// Get 'post_id' parameter
let postId = params.post_id;
if (postId === undefined || postId === null) {
return rej('post_id is required');
}
const [postId, postIdErr] = it(params.post_id, 'id', true);
if (postIdErr) return rej('invalid post_id param');
// Get favoritee
const post = await Post.findOne({

View File

@@ -3,9 +3,9 @@
/**
* Module dependencies
*/
import * as mongo from 'mongodb';
import Favorite from '../../models/favorite';
import Post from '../../models/post';
import it from '../../../it';
import Favorite from '../../../models/favorite';
import Post from '../../../models/post';
/**
* Unfavorite a post
@@ -17,10 +17,8 @@ import Post from '../../models/post';
module.exports = (params, user) =>
new Promise(async (res, rej) => {
// Get 'post_id' parameter
let postId = params.post_id;
if (postId === undefined || postId === null) {
return rej('post_id is required');
}
const [postId, postIdErr] = it(params.post_id, 'id', true);
if (postIdErr) return rej('invalid post_id param');
// Get favoritee
const post = await Post.findOne({