From 034c7c083adf5433f1956753cd1b98d54483db4a Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 5 Mar 2017 12:09:34 +0900 Subject: [PATCH] fix --- src/api/common/notify.ts | 2 +- src/api/endpoints.ts | 2 +- src/api/endpoints/app/show.ts | 4 ++-- src/api/endpoints/following/create.ts | 2 +- src/api/endpoints/following/delete.ts | 2 +- src/api/endpoints/posts/context.ts | 2 +- src/api/endpoints/posts/create.ts | 10 +++++----- src/api/endpoints/posts/favorites/create.ts | 2 +- src/api/endpoints/posts/favorites/delete.ts | 2 +- src/api/endpoints/posts/likes.ts | 2 +- src/api/endpoints/posts/likes/create.ts | 2 +- src/api/endpoints/posts/likes/delete.ts | 2 +- src/api/endpoints/posts/polls/vote.ts | 2 +- src/api/endpoints/posts/replies.ts | 4 ++-- src/api/endpoints/posts/reposts.ts | 2 +- src/api/endpoints/posts/show.ts | 2 +- src/api/endpoints/users/followers.ts | 2 +- src/api/endpoints/users/following.ts | 4 ++-- src/api/endpoints/users/posts.ts | 4 ++-- src/api/endpoints/users/show.ts | 4 ++-- 20 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/api/common/notify.ts b/src/api/common/notify.ts index 9152b85cdb..e7ec37d4e4 100644 --- a/src/api/common/notify.ts +++ b/src/api/common/notify.ts @@ -7,7 +7,7 @@ export default ( notifiee: mongo.ObjectID, notifier: mongo.ObjectID, type: string, - content: any + content?: any ) => new Promise(async (resolve, reject) => { if (notifiee.equals(notifier)) { return resolve(); diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index e19297207f..b8388fea42 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -1,4 +1,4 @@ -import * as ms from 'ms'; +const ms = require('ms'); /** * エンドポイントを表します。 diff --git a/src/api/endpoints/app/show.ts b/src/api/endpoints/app/show.ts index e4aa3dc0fd..88698d5cd8 100644 --- a/src/api/endpoints/app/show.ts +++ b/src/api/endpoints/app/show.ts @@ -46,11 +46,11 @@ import serialize from '../../serializers/app'; */ module.exports = (params, user, _, isSecure) => new Promise(async (res, rej) => { // Get 'app_id' parameter - const [appId, appIdErr] = it(params.app_id, 'id'); + const [appId, appIdErr] = it(params.app_id, 'id').get(); if (appIdErr) return rej('invalid app_id param'); // Get 'name_id' parameter - const [nameId, nameIdErr] = it(params.name_id, 'string'); + const [nameId, nameIdErr] = it(params.name_id, 'string').get(); if (nameIdErr) return rej('invalid name_id param'); if (appId === undefined && nameId === undefined) { diff --git a/src/api/endpoints/following/create.ts b/src/api/endpoints/following/create.ts index 45c93ef056..28a69844c2 100644 --- a/src/api/endpoints/following/create.ts +++ b/src/api/endpoints/following/create.ts @@ -19,7 +19,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { const follower = user; // Get 'user_id' parameter - const [userId, userIdErr] = it(params.user_id, 'id', true); + const [userId, userIdErr] = it(params.user_id, 'id!').get(); if (userIdErr) return rej('invalid user_id param'); // 自分自身 diff --git a/src/api/endpoints/following/delete.ts b/src/api/endpoints/following/delete.ts index b75fa770e0..f8c4541552 100644 --- a/src/api/endpoints/following/delete.ts +++ b/src/api/endpoints/following/delete.ts @@ -18,7 +18,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { const follower = user; // Get 'user_id' parameter - const [userId, userIdErr] = it(params.user_id, 'id', true); + const [userId, userIdErr] = it(params.user_id, 'id!').get(); if (userIdErr) return rej('invalid user_id param'); // Check if the followee is yourself diff --git a/src/api/endpoints/posts/context.ts b/src/api/endpoints/posts/context.ts index 11dd43fe97..03f5a95800 100644 --- a/src/api/endpoints/posts/context.ts +++ b/src/api/endpoints/posts/context.ts @@ -14,7 +14,7 @@ import serialize from '../../serializers/post'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'post_id' parameter - const [postId, postIdErr] = it(params.post_id, 'id', true); + const [postId, postIdErr] = it(params.post_id, 'id!').get(); if (postIdErr) return rej('invalid post_id param'); // Get 'limit' parameter diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts index 3737012a30..80a8e57e62 100644 --- a/src/api/endpoints/posts/create.ts +++ b/src/api/endpoints/posts/create.ts @@ -88,20 +88,20 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => { if (latestPost && latestPost.repost_id && latestPost.repost_id.equals(repost._id) && - text === null && files === null) { + text === undefined && files === null) { return rej('二重Repostです(NEED TRANSLATE)'); } // 直近がRepost対象かつ引用じゃなかったらエラー if (latestPost && latestPost._id.equals(repost._id) && - text === null && files === null) { + text === undefined && files === null) { return rej('二重Repostです(NEED TRANSLATE)'); } } // Get 'in_reply_to_post_id' parameter - const [inReplyToPostId, inReplyToPostIdErr] = it(params.reply_to_id, 'id'); + const [inReplyToPostId, inReplyToPostIdErr] = it(params.reply_to_id, 'id').get(); if (inReplyToPostIdErr) return rej('invalid in_reply_to_post_id'); let inReplyToPost = null; @@ -122,7 +122,7 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => { } // Get 'poll' parameter - const [_poll, pollErr] = it(params.poll, 'object'); + const [_poll, pollErr] = it(params.poll, 'object').get(); if (pollErr) return rej('invalid poll'); let poll = null; @@ -151,7 +151,7 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => { } // テキストが無いかつ添付ファイルが無いかつRepostも無いかつ投票も無かったらエラー - if (text === null && files === null && repost === null && poll === null) { + if (text === undefined && files === null && repost === null && poll === null) { return rej('text, media_ids, repost_id or poll is required'); } diff --git a/src/api/endpoints/posts/favorites/create.ts b/src/api/endpoints/posts/favorites/create.ts index bf316b3573..96edf0eb27 100644 --- a/src/api/endpoints/posts/favorites/create.ts +++ b/src/api/endpoints/posts/favorites/create.ts @@ -14,7 +14,7 @@ import Post from '../../../models/post'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'post_id' parameter - const [postId, postIdErr] = it(params.post_id, 'id', true); + const [postId, postIdErr] = it(params.post_id, 'id!').get(); if (postIdErr) return rej('invalid post_id param'); // Get favoritee diff --git a/src/api/endpoints/posts/favorites/delete.ts b/src/api/endpoints/posts/favorites/delete.ts index 5d4ad0a79d..5179fad9a5 100644 --- a/src/api/endpoints/posts/favorites/delete.ts +++ b/src/api/endpoints/posts/favorites/delete.ts @@ -14,7 +14,7 @@ import Post from '../../../models/post'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'post_id' parameter - const [postId, postIdErr] = it(params.post_id, 'id', true); + const [postId, postIdErr] = it(params.post_id, 'id!').get(); if (postIdErr) return rej('invalid post_id param'); // Get favoritee diff --git a/src/api/endpoints/posts/likes.ts b/src/api/endpoints/posts/likes.ts index 8aca5f9904..23933237a7 100644 --- a/src/api/endpoints/posts/likes.ts +++ b/src/api/endpoints/posts/likes.ts @@ -15,7 +15,7 @@ import serialize from '../../serializers/user'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'post_id' parameter - const [postId, postIdErr] = it(params.post_id, 'id', true); + const [postId, postIdErr] = it(params.post_id, 'id!').get(); if (postIdErr) return rej('invalid post_id param'); // Get 'limit' parameter diff --git a/src/api/endpoints/posts/likes/create.ts b/src/api/endpoints/posts/likes/create.ts index 9447cba247..db8b6d0b20 100644 --- a/src/api/endpoints/posts/likes/create.ts +++ b/src/api/endpoints/posts/likes/create.ts @@ -16,7 +16,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', true); + const [postId, postIdErr] = it(params.post_id, 'id!').get(); if (postIdErr) return rej('invalid post_id param'); // Get likee diff --git a/src/api/endpoints/posts/likes/delete.ts b/src/api/endpoints/posts/likes/delete.ts index 411a1d53ca..8d9fe273db 100644 --- a/src/api/endpoints/posts/likes/delete.ts +++ b/src/api/endpoints/posts/likes/delete.ts @@ -16,7 +16,7 @@ import User from '../../../models/user'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'post_id' parameter - const [postId, postIdErr] = it(params.post_id, 'id', true); + const [postId, postIdErr] = it(params.post_id, 'id!').get(); if (postIdErr) return rej('invalid post_id param'); // Get likee diff --git a/src/api/endpoints/posts/polls/vote.ts b/src/api/endpoints/posts/polls/vote.ts index d049041b2f..04e380807f 100644 --- a/src/api/endpoints/posts/polls/vote.ts +++ b/src/api/endpoints/posts/polls/vote.ts @@ -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', true); + const [postId, postIdErr] = it(params.post_id, 'id!').get(); if (postIdErr) return rej('invalid post_id param'); // Get votee diff --git a/src/api/endpoints/posts/replies.ts b/src/api/endpoints/posts/replies.ts index 9279cd66f6..4516dce15c 100644 --- a/src/api/endpoints/posts/replies.ts +++ b/src/api/endpoints/posts/replies.ts @@ -14,11 +14,11 @@ import serialize from '../../serializers/post'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'post_id' parameter - const [postId, postIdErr] = it(params.post_id, 'id', true); + const [postId, postIdErr] = it(params.post_id, 'id!').get(); if (postIdErr) return rej('invalid post_id param'); // Get 'limit' parameter - const [limit = 10, limitErr] = it(params.limit).expect.number().range(1, 100)).get(); + const [limit = 10, limitErr] = it(params.limit).expect.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'offset' parameter diff --git a/src/api/endpoints/posts/reposts.ts b/src/api/endpoints/posts/reposts.ts index 14de17992d..5098d5af81 100644 --- a/src/api/endpoints/posts/reposts.ts +++ b/src/api/endpoints/posts/reposts.ts @@ -14,7 +14,7 @@ import serialize from '../../serializers/post'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'post_id' parameter - const [postId, postIdErr] = it(params.post_id, 'id', true); + const [postId, postIdErr] = it(params.post_id, 'id!').get(); if (postIdErr) return rej('invalid post_id param'); // Get 'limit' parameter diff --git a/src/api/endpoints/posts/show.ts b/src/api/endpoints/posts/show.ts index e19a3dae78..e0bed903b4 100644 --- a/src/api/endpoints/posts/show.ts +++ b/src/api/endpoints/posts/show.ts @@ -14,7 +14,7 @@ import serialize from '../../serializers/post'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'post_id' parameter - const [postId, postIdErr] = it(params.post_id, 'id', true); + const [postId, postIdErr] = it(params.post_id, 'id!').get(); if (postIdErr) return rej('invalid post_id param'); // Get post diff --git a/src/api/endpoints/users/followers.ts b/src/api/endpoints/users/followers.ts index 09bc5d83ef..1b032245c8 100644 --- a/src/api/endpoints/users/followers.ts +++ b/src/api/endpoints/users/followers.ts @@ -16,7 +16,7 @@ import getFriends from '../../common/get-friends'; */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'user_id' parameter - const [userId, userIdErr] = it(params.user_id, 'id', true); + const [userId, userIdErr] = it(params.user_id, 'id!').get(); if (userIdErr) return rej('invalid user_id param'); // Get 'iknow' parameter diff --git a/src/api/endpoints/users/following.ts b/src/api/endpoints/users/following.ts index a6f51410d7..8eb175970b 100644 --- a/src/api/endpoints/users/following.ts +++ b/src/api/endpoints/users/following.ts @@ -16,11 +16,11 @@ import getFriends from '../../common/get-friends'; */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'user_id' parameter - const [userId, userIdErr] = it(params.user_id, 'id', true); + const [userId, userIdErr] = it(params.user_id, 'id!').get(); if (userIdErr) return rej('invalid user_id param'); // Get 'iknow' parameter - const [iknow = false, iknowErr] = it(params.iknow).expect.boolean(.get(); + const [iknow = false, iknowErr] = it(params.iknow).expect.boolean().get(); if (iknowErr) return rej('invalid iknow param'); // Get 'limit' parameter diff --git a/src/api/endpoints/users/posts.ts b/src/api/endpoints/users/posts.ts index af7082457a..7ac9f78237 100644 --- a/src/api/endpoints/users/posts.ts +++ b/src/api/endpoints/users/posts.ts @@ -15,11 +15,11 @@ import serialize from '../../serializers/post'; */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'user_id' parameter - const [userId, userIdErr] = it(params.user_id, 'id'); + const [userId, userIdErr] = it(params.user_id, 'id').get(); if (userIdErr) return rej('invalid user_id param'); // Get 'username' parameter - const [username, usernameErr] = it(params.username, 'string'); + const [username, usernameErr] = it(params.username, 'string').get(); if (usernameErr) return rej('invalid username param'); if (userId === undefined && username === undefined) { diff --git a/src/api/endpoints/users/show.ts b/src/api/endpoints/users/show.ts index 2a8d9c7724..897e777fb6 100644 --- a/src/api/endpoints/users/show.ts +++ b/src/api/endpoints/users/show.ts @@ -14,11 +14,11 @@ import serialize from '../../serializers/user'; */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'user_id' parameter - const [userId, userIdErr] = it(params.user_id, 'id'); + const [userId, userIdErr] = it(params.user_id, 'id').get(); if (userIdErr) return rej('invalid user_id param'); // Get 'username' parameter - const [username, usernameErr] = it(params.username, 'string'); + const [username, usernameErr] = it(params.username, 'string').get(); if (usernameErr) return rej('invalid username param'); if (userId === undefined && username === undefined) {