summaryrefslogtreecommitdiff
path: root/src/api/endpoints/posts/polls
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-09 03:50:09 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-09 03:50:09 +0900
commit31f36fa618e02bab9776a943366167e1009ede48 (patch)
tree386dbaa963b3695f6a0febf9b5076e8d42006536 /src/api/endpoints/posts/polls
parentMerge pull request #237 from syuilo/greenkeeper/cafy-1.2.0 (diff)
downloadsharkey-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.ts11
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