From 31f36fa618e02bab9776a943366167e1009ede48 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 9 Mar 2017 03:50:09 +0900 Subject: :v: --- src/api/endpoints/posts/polls/vote.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/api/endpoints/posts/polls') diff --git a/src/api/endpoints/posts/polls/vote.ts b/src/api/endpoints/posts/polls/vote.ts index 04e380807f..e345497905 100644 --- a/src/api/endpoints/posts/polls/vote.ts +++ b/src/api/endpoints/posts/polls/vote.ts @@ -1,7 +1,7 @@ /** * Module dependencies */ -import it from 'cafy'; +import $ from 'cafy'; import Vote from '../../../models/poll-vote'; import Post from '../../../models/post'; import notify from '../../../common/notify'; @@ -15,7 +15,7 @@ import notify from '../../../common/notify'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'post_id' parameter - const [postId, postIdErr] = it(params.post_id, 'id!').get(); + const [postId, postIdErr] = $(params.post_id).id().$; if (postIdErr) return rej('invalid post_id param'); // Get votee @@ -33,10 +33,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'choice' parameter const [choice, choiceError] = - it(params.choice).expect.string() - .required() - .validate(c => post.poll.choices.some(x => x.id == c)) - .get(); + $(params.choice).string() + .pipe(c => post.poll.choices.some(x => x.id == c)) + .$; if (choiceError) return rej('invalid choice param'); // if already voted -- cgit v1.2.3-freya