[API] Fix bug
This commit is contained in:
parent
66eed481ea
commit
3a58cff9b2
|
@ -57,12 +57,12 @@ module.exports = (params, user, _, isSecure) =>
|
||||||
const [nameId, nameIdErr] = it(params.name_id, 'string');
|
const [nameId, nameIdErr] = it(params.name_id, 'string');
|
||||||
if (nameIdErr) return rej('invalid name_id param');
|
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');
|
return rej('app_id or name_id is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup app
|
// Lookup app
|
||||||
const app = appId !== null
|
const app = appId !== undefined
|
||||||
? await App.findOne({ _id: appId })
|
? await App.findOne({ _id: appId })
|
||||||
: await App.findOne({ name_id_lower: nameId.toLowerCase() });
|
: await App.findOne({ name_id_lower: nameId.toLowerCase() });
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ module.exports = (params, user, app) =>
|
||||||
if (mediaIdsErr) return rej('invalid media_ids');
|
if (mediaIdsErr) return rej('invalid media_ids');
|
||||||
|
|
||||||
let files = [];
|
let files = [];
|
||||||
if (mediaIds !== null) {
|
if (mediaIds !== undefined) {
|
||||||
// Fetch files
|
// Fetch files
|
||||||
// forEach だと途中でエラーなどがあっても return できないので
|
// forEach だと途中でエラーなどがあっても return できないので
|
||||||
// 敢えて for を使っています。
|
// 敢えて for を使っています。
|
||||||
|
@ -67,7 +67,7 @@ module.exports = (params, user, app) =>
|
||||||
if (repostIdErr) return rej('invalid repost_id');
|
if (repostIdErr) return rej('invalid repost_id');
|
||||||
|
|
||||||
let repost = null;
|
let repost = null;
|
||||||
if (repostId !== null) {
|
if (repostId !== undefined) {
|
||||||
// Fetch repost to post
|
// Fetch repost to post
|
||||||
repost = await Post.findOne({
|
repost = await Post.findOne({
|
||||||
_id: repostId
|
_id: repostId
|
||||||
|
@ -109,7 +109,7 @@ module.exports = (params, user, app) =>
|
||||||
if (inReplyToPostIdErr) return rej('invalid in_reply_to_post_id');
|
if (inReplyToPostIdErr) return rej('invalid in_reply_to_post_id');
|
||||||
|
|
||||||
let inReplyToPost = null;
|
let inReplyToPost = null;
|
||||||
if (inReplyToPostId !== null) {
|
if (inReplyToPostId !== undefined) {
|
||||||
// Fetch reply
|
// Fetch reply
|
||||||
inReplyToPost = await Post.findOne({
|
inReplyToPost = await Post.findOne({
|
||||||
_id: inReplyToPostId
|
_id: inReplyToPostId
|
||||||
|
@ -130,7 +130,7 @@ module.exports = (params, user, app) =>
|
||||||
if (pollErr) return rej('invalid poll');
|
if (pollErr) return rej('invalid poll');
|
||||||
|
|
||||||
let poll = null;
|
let poll = null;
|
||||||
if (_poll !== null) {
|
if (_poll !== undefined) {
|
||||||
const [pollChoices, pollChoicesErr] =
|
const [pollChoices, pollChoicesErr] =
|
||||||
it(params.poll).expect.array()
|
it(params.poll).expect.array()
|
||||||
.unique()
|
.unique()
|
||||||
|
|
|
@ -26,7 +26,7 @@ module.exports = (params, me) =>
|
||||||
const [username, usernameErr] = it(params.username, 'string');
|
const [username, usernameErr] = it(params.username, 'string');
|
||||||
if (usernameErr) return rej('invalid username param');
|
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');
|
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');
|
return rej('cannot set since_id and max_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
const q = userId != null
|
const q = userId !== undefined
|
||||||
? { _id: userId }
|
? { _id: userId }
|
||||||
: { username_lower: username.toLowerCase() } ;
|
: { username_lower: username.toLowerCase() } ;
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,11 @@ module.exports = (params, me) =>
|
||||||
const [username, usernameErr] = it(params.username, 'string');
|
const [username, usernameErr] = it(params.username, 'string');
|
||||||
if (usernameErr) return rej('invalid username param');
|
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');
|
return rej('user_id or username is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
const q = userId != null
|
const q = userId !== undefined
|
||||||
? { _id: userId }
|
? { _id: userId }
|
||||||
: { username_lower: username.toLowerCase() };
|
: { username_lower: username.toLowerCase() };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue