summaryrefslogtreecommitdiff
path: root/src/api/endpoints
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-03 20:28:42 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-03 20:28:42 +0900
commit3a58cff9b2b49c103b1d51a951ec269a8929d6df (patch)
treee311e00483751c7e6ff161a79cea4f94bcd49797 /src/api/endpoints
parent[API] Fix bug (diff)
downloadsharkey-3a58cff9b2b49c103b1d51a951ec269a8929d6df.tar.gz
sharkey-3a58cff9b2b49c103b1d51a951ec269a8929d6df.tar.bz2
sharkey-3a58cff9b2b49c103b1d51a951ec269a8929d6df.zip
[API] Fix bug
Diffstat (limited to 'src/api/endpoints')
-rw-r--r--src/api/endpoints/app/show.ts4
-rw-r--r--src/api/endpoints/posts/create.ts8
-rw-r--r--src/api/endpoints/users/posts.ts4
-rw-r--r--src/api/endpoints/users/show.ts6
4 files changed, 11 insertions, 11 deletions
diff --git a/src/api/endpoints/app/show.ts b/src/api/endpoints/app/show.ts
index cfb03bb9e5..6b6e4f010c 100644
--- a/src/api/endpoints/app/show.ts
+++ b/src/api/endpoints/app/show.ts
@@ -57,12 +57,12 @@ module.exports = (params, user, _, isSecure) =>
const [nameId, nameIdErr] = it(params.name_id, 'string');
if (nameIdErr) return rej('invalid name_id param');
- if (appId === null && nameId === null) {
+ if (appId === undefined && nameId === undefined) {
return rej('app_id or name_id is required');
}
// Lookup app
- const app = appId !== null
+ const app = appId !== undefined
? await App.findOne({ _id: appId })
: await App.findOne({ name_id_lower: nameId.toLowerCase() });
diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts
index 3dc121305c..d558cd3018 100644
--- a/src/api/endpoints/posts/create.ts
+++ b/src/api/endpoints/posts/create.ts
@@ -35,7 +35,7 @@ module.exports = (params, user, app) =>
if (mediaIdsErr) return rej('invalid media_ids');
let files = [];
- if (mediaIds !== null) {
+ if (mediaIds !== undefined) {
// Fetch files
// forEach だと途中でエラーなどがあっても return できないので
// 敢えて for を使っています。
@@ -67,7 +67,7 @@ module.exports = (params, user, app) =>
if (repostIdErr) return rej('invalid repost_id');
let repost = null;
- if (repostId !== null) {
+ if (repostId !== undefined) {
// Fetch repost to post
repost = await Post.findOne({
_id: repostId
@@ -109,7 +109,7 @@ module.exports = (params, user, app) =>
if (inReplyToPostIdErr) return rej('invalid in_reply_to_post_id');
let inReplyToPost = null;
- if (inReplyToPostId !== null) {
+ if (inReplyToPostId !== undefined) {
// Fetch reply
inReplyToPost = await Post.findOne({
_id: inReplyToPostId
@@ -130,7 +130,7 @@ module.exports = (params, user, app) =>
if (pollErr) return rej('invalid poll');
let poll = null;
- if (_poll !== null) {
+ if (_poll !== undefined) {
const [pollChoices, pollChoicesErr] =
it(params.poll).expect.array()
.unique()
diff --git a/src/api/endpoints/users/posts.ts b/src/api/endpoints/users/posts.ts
index 770831c426..78f91b16c5 100644
--- a/src/api/endpoints/users/posts.ts
+++ b/src/api/endpoints/users/posts.ts
@@ -26,7 +26,7 @@ module.exports = (params, me) =>
const [username, usernameErr] = it(params.username, 'string');
if (usernameErr) return rej('invalid username param');
- if (userId === null && username === null) {
+ if (userId === undefined && username === undefined) {
return rej('user_id or username is required');
}
@@ -55,7 +55,7 @@ module.exports = (params, me) =>
return rej('cannot set since_id and max_id');
}
- const q = userId != null
+ const q = userId !== undefined
? { _id: userId }
: { username_lower: username.toLowerCase() } ;
diff --git a/src/api/endpoints/users/show.ts b/src/api/endpoints/users/show.ts
index cae4ac0b7f..9997d2ba03 100644
--- a/src/api/endpoints/users/show.ts
+++ b/src/api/endpoints/users/show.ts
@@ -25,13 +25,13 @@ module.exports = (params, me) =>
const [username, usernameErr] = it(params.username, 'string');
if (usernameErr) return rej('invalid username param');
- if (userId === null && username === null) {
+ if (userId === undefined && username === undefined) {
return rej('user_id or username is required');
}
- const q = userId != null
+ const q = userId !== undefined
? { _id: userId }
- : { username_lower: username.toLowerCase() } ;
+ : { username_lower: username.toLowerCase() };
// Lookup user
const user = await User.findOne(q, {