This commit is contained in:
syuilo 2017-03-05 12:09:34 +09:00
parent 17a23c3eb5
commit 034c7c083a
20 changed files with 29 additions and 29 deletions

View File

@ -7,7 +7,7 @@ export default (
notifiee: mongo.ObjectID,
notifier: mongo.ObjectID,
type: string,
content: any
content?: any
) => new Promise<any>(async (resolve, reject) => {
if (notifiee.equals(notifier)) {
return resolve();

View File

@ -1,4 +1,4 @@
import * as ms from 'ms';
const ms = require('ms');
/**
*

View File

@ -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) {

View File

@ -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');
// 自分自身

View File

@ -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

View File

@ -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

View File

@ -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');
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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) {

View File

@ -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) {