summaryrefslogtreecommitdiff
path: root/src/api/endpoints/posts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-05 12:09:34 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-05 12:09:34 +0900
commit034c7c083adf5433f1956753cd1b98d54483db4a (patch)
tree2e41ea90e53d1349abf44444c2f1e6b2ec3de783 /src/api/endpoints/posts
parentUse cafy (diff)
downloadsharkey-034c7c083adf5433f1956753cd1b98d54483db4a.tar.gz
sharkey-034c7c083adf5433f1956753cd1b98d54483db4a.tar.bz2
sharkey-034c7c083adf5433f1956753cd1b98d54483db4a.zip
fix
Diffstat (limited to 'src/api/endpoints/posts')
-rw-r--r--src/api/endpoints/posts/context.ts2
-rw-r--r--src/api/endpoints/posts/create.ts10
-rw-r--r--src/api/endpoints/posts/favorites/create.ts2
-rw-r--r--src/api/endpoints/posts/favorites/delete.ts2
-rw-r--r--src/api/endpoints/posts/likes.ts2
-rw-r--r--src/api/endpoints/posts/likes/create.ts2
-rw-r--r--src/api/endpoints/posts/likes/delete.ts2
-rw-r--r--src/api/endpoints/posts/polls/vote.ts2
-rw-r--r--src/api/endpoints/posts/replies.ts4
-rw-r--r--src/api/endpoints/posts/reposts.ts2
-rw-r--r--src/api/endpoints/posts/show.ts2
11 files changed, 16 insertions, 16 deletions
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