summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-06 03:50:27 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-06 03:50:27 +0900
commit79c264171d69992ce76f4ceec2bd03b0e5faaac3 (patch)
tree184d909156a10bb073376f3d89cd548648f48bda /src
parentMerge pull request #235 from syuilo/greenkeeper/cafy-1.0.1 (diff)
downloadsharkey-79c264171d69992ce76f4ceec2bd03b0e5faaac3.tar.gz
sharkey-79c264171d69992ce76f4ceec2bd03b0e5faaac3.tar.bz2
sharkey-79c264171d69992ce76f4ceec2bd03b0e5faaac3.zip
[]API Fix bugs
Diffstat (limited to 'src')
-rw-r--r--src/api/endpoints/i/update.ts4
-rw-r--r--src/api/endpoints/messaging/messages/create.ts4
-rw-r--r--src/api/endpoints/posts/create.ts7
3 files changed, 8 insertions, 7 deletions
diff --git a/src/api/endpoints/i/update.ts b/src/api/endpoints/i/update.ts
index fddee6a1b1..dd5a7dd240 100644
--- a/src/api/endpoints/i/update.ts
+++ b/src/api/endpoints/i/update.ts
@@ -31,12 +31,12 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re
// Get 'location' parameter
const [location, locationErr] = it(params.location).expect.nullable.string().validate(isValidLocation).get();
if (locationErr) return rej('invalid location param');
- if (location !== undefined) user.location = location;
+ if (location !== undefined) user.profile.location = location;
// Get 'birthday' parameter
const [birthday, birthdayErr] = it(params.birthday).expect.nullable.string().validate(isValidBirthday).get();
if (birthdayErr) return rej('invalid birthday param');
- if (birthday !== undefined) user.birthday = birthday;
+ if (birthday !== undefined) user.profile.birthday = birthday;
// Get 'avatar_id' parameter
const [avatarId, avatarIdErr] = it(params.avatar_id).expect.id().get();
diff --git a/src/api/endpoints/messaging/messages/create.ts b/src/api/endpoints/messaging/messages/create.ts
index a63e8b1959..dc3556da0d 100644
--- a/src/api/endpoints/messaging/messages/create.ts
+++ b/src/api/endpoints/messaging/messages/create.ts
@@ -51,7 +51,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
if (fileIdErr) return rej('invalid file_id param');
let file = null;
- if (fileId !== null) {
+ if (fileId !== undefined) {
file = await DriveFile.findOne({
_id: fileId,
user_id: user._id
@@ -65,7 +65,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
}
// テキストが無いかつ添付ファイルも無かったらエラー
- if (text === null && file === null) {
+ if (text === undefined && file === null) {
return rej('text or file is required');
}
diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts
index 80a8e57e62..7f952e83be 100644
--- a/src/api/endpoints/posts/create.ts
+++ b/src/api/endpoints/posts/create.ts
@@ -2,7 +2,7 @@
* Module dependencies
*/
import it from 'cafy';
-import parse from '../../../common/text';
+const parse = require('../../../common/text');
import Post from '../../models/post';
import { isValidText } from '../../models/post';
import User from '../../models/user';
@@ -128,10 +128,11 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => {
let poll = null;
if (_poll !== undefined) {
const [pollChoices, pollChoicesErr] =
- it(params.poll).expect.array()
+ it(params.poll.choices).expect.array()
+ .required()
.unique()
.allString()
- .range(1, 10)
+ .range(2, 10)
.validate(choices => !choices.some(choice => {
if (typeof choice != 'string') return true;
if (choice.trim().length == 0) return true;