diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-03-09 03:50:09 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-03-09 03:50:09 +0900 |
| commit | 31f36fa618e02bab9776a943366167e1009ede48 (patch) | |
| tree | 386dbaa963b3695f6a0febf9b5076e8d42006536 /src/api/endpoints/posts/polls | |
| parent | Merge pull request #237 from syuilo/greenkeeper/cafy-1.2.0 (diff) | |
| download | sharkey-31f36fa618e02bab9776a943366167e1009ede48.tar.gz sharkey-31f36fa618e02bab9776a943366167e1009ede48.tar.bz2 sharkey-31f36fa618e02bab9776a943366167e1009ede48.zip | |
:v:
Diffstat (limited to 'src/api/endpoints/posts/polls')
| -rw-r--r-- | src/api/endpoints/posts/polls/vote.ts | 11 |
1 files changed, 5 insertions, 6 deletions
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 |