diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2018-04-26 16:10:25 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-26 16:10:25 +0900 |
| commit | 5d4b884528e0533e32b9c827ae8ccf64df0085dc (patch) | |
| tree | 1f6a3238dfbf1f77da78d96e993f6d76cad73089 /src/server/api/endpoints/i | |
| parent | Refactor (diff) | |
| parent | wip (diff) | |
| download | sharkey-5d4b884528e0533e32b9c827ae8ccf64df0085dc.tar.gz sharkey-5d4b884528e0533e32b9c827ae8ccf64df0085dc.tar.bz2 sharkey-5d4b884528e0533e32b9c827ae8ccf64df0085dc.zip | |
Merge pull request #1550 from syuilo/user-list
User list
Diffstat (limited to 'src/server/api/endpoints/i')
| -rw-r--r-- | src/server/api/endpoints/i/authorized_apps.ts | 4 | ||||
| -rw-r--r-- | src/server/api/endpoints/i/change_password.ts | 4 | ||||
| -rw-r--r-- | src/server/api/endpoints/i/favorites.ts | 6 | ||||
| -rw-r--r-- | src/server/api/endpoints/i/notifications.ts | 8 | ||||
| -rw-r--r-- | src/server/api/endpoints/i/pin.ts | 8 | ||||
| -rw-r--r-- | src/server/api/endpoints/i/regenerate_token.ts | 4 | ||||
| -rw-r--r-- | src/server/api/endpoints/i/signin_history.ts | 10 | ||||
| -rw-r--r-- | src/server/api/endpoints/i/update.ts | 6 | ||||
| -rw-r--r-- | src/server/api/endpoints/i/update_client_setting.ts | 4 | ||||
| -rw-r--r-- | src/server/api/endpoints/i/update_home.ts | 2 | ||||
| -rw-r--r-- | src/server/api/endpoints/i/update_mobile_home.ts | 2 |
11 files changed, 17 insertions, 41 deletions
diff --git a/src/server/api/endpoints/i/authorized_apps.ts b/src/server/api/endpoints/i/authorized_apps.ts index 82fd2d2516..fd12b3dec0 100644 --- a/src/server/api/endpoints/i/authorized_apps.ts +++ b/src/server/api/endpoints/i/authorized_apps.ts @@ -7,10 +7,6 @@ import { pack } from '../../../../models/app'; /** * Get authorized apps of my account - * - * @param {any} params - * @param {any} user - * @return {Promise<any>} */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'limit' parameter diff --git a/src/server/api/endpoints/i/change_password.ts b/src/server/api/endpoints/i/change_password.ts index 57415083f1..a24e9f0be1 100644 --- a/src/server/api/endpoints/i/change_password.ts +++ b/src/server/api/endpoints/i/change_password.ts @@ -7,10 +7,6 @@ import User from '../../../../models/user'; /** * Change password - * - * @param {any} params - * @param {any} user - * @return {Promise<any>} */ module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'currentPasword' parameter diff --git a/src/server/api/endpoints/i/favorites.ts b/src/server/api/endpoints/i/favorites.ts index f390ef9ec7..a2c472ad17 100644 --- a/src/server/api/endpoints/i/favorites.ts +++ b/src/server/api/endpoints/i/favorites.ts @@ -1,7 +1,7 @@ /** * Module dependencies */ -import $ from 'cafy'; +import $ from 'cafy'; import ID from '../../../../cafy-id'; import Favorite, { pack } from '../../../../models/favorite'; /** @@ -13,11 +13,11 @@ module.exports = (params, user) => new Promise(async (res, rej) => { if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.id().$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.id().$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified diff --git a/src/server/api/endpoints/i/notifications.ts b/src/server/api/endpoints/i/notifications.ts index 69a8910898..14ade7b023 100644 --- a/src/server/api/endpoints/i/notifications.ts +++ b/src/server/api/endpoints/i/notifications.ts @@ -1,7 +1,7 @@ /** * Module dependencies */ -import $ from 'cafy'; +import $ from 'cafy'; import ID from '../../../../cafy-id'; import Notification from '../../../../models/notification'; import Mute from '../../../../models/mute'; import { pack } from '../../../../models/notification'; @@ -22,7 +22,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { if (markAsReadErr) return rej('invalid markAsRead param'); // Get 'type' parameter - const [type, typeErr] = $(params.type).optional.array('string').unique().$; + const [type, typeErr] = $(params.type).optional.array($().string()).unique().$; if (typeErr) return rej('invalid type param'); // Get 'limit' parameter @@ -30,11 +30,11 @@ module.exports = (params, user) => new Promise(async (res, rej) => { if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.id().$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.id().$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified diff --git a/src/server/api/endpoints/i/pin.ts b/src/server/api/endpoints/i/pin.ts index 909a6fdbde..761e41bbea 100644 --- a/src/server/api/endpoints/i/pin.ts +++ b/src/server/api/endpoints/i/pin.ts @@ -1,21 +1,17 @@ /** * Module dependencies */ -import $ from 'cafy'; +import $ from 'cafy'; import ID from '../../../../cafy-id'; import User from '../../../../models/user'; import Note from '../../../../models/note'; import { pack } from '../../../../models/user'; /** * Pin note - * - * @param {any} params - * @param {any} user - * @return {Promise<any>} */ module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'noteId' parameter - const [noteId, noteIdErr] = $(params.noteId).id().$; + const [noteId, noteIdErr] = $(params.noteId).type(ID).$; if (noteIdErr) return rej('invalid noteId param'); // Fetch pinee diff --git a/src/server/api/endpoints/i/regenerate_token.ts b/src/server/api/endpoints/i/regenerate_token.ts index f9e92c1797..945ddbdee4 100644 --- a/src/server/api/endpoints/i/regenerate_token.ts +++ b/src/server/api/endpoints/i/regenerate_token.ts @@ -9,10 +9,6 @@ import generateUserToken from '../../common/generate-native-user-token'; /** * Regenerate native token - * - * @param {any} params - * @param {any} user - * @return {Promise<any>} */ module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'password' parameter diff --git a/src/server/api/endpoints/i/signin_history.ts b/src/server/api/endpoints/i/signin_history.ts index 931b9e2252..77beca9fd6 100644 --- a/src/server/api/endpoints/i/signin_history.ts +++ b/src/server/api/endpoints/i/signin_history.ts @@ -1,15 +1,11 @@ /** * Module dependencies */ -import $ from 'cafy'; +import $ from 'cafy'; import ID from '../../../../cafy-id'; import Signin, { pack } from '../../../../models/signin'; /** * Get signin history of my account - * - * @param {any} params - * @param {any} user - * @return {Promise<any>} */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'limit' parameter @@ -17,11 +13,11 @@ module.exports = (params, user) => new Promise(async (res, rej) => { if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.id().$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.id().$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts index f3c9d777b5..7505e73387 100644 --- a/src/server/api/endpoints/i/update.ts +++ b/src/server/api/endpoints/i/update.ts @@ -1,7 +1,7 @@ /** * Module dependencies */ -import $ from 'cafy'; +import $ from 'cafy'; import ID from '../../../../cafy-id'; import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../../../models/user'; import event from '../../../../publishers/stream'; @@ -32,12 +32,12 @@ module.exports = async (params, user, app) => new Promise(async (res, rej) => { if (birthday !== undefined) user.profile.birthday = birthday; // Get 'avatarId' parameter - const [avatarId, avatarIdErr] = $(params.avatarId).optional.id().$; + const [avatarId, avatarIdErr] = $(params.avatarId).optional.type(ID).$; if (avatarIdErr) return rej('invalid avatarId param'); if (avatarId) user.avatarId = avatarId; // Get 'bannerId' parameter - const [bannerId, bannerIdErr] = $(params.bannerId).optional.id().$; + const [bannerId, bannerIdErr] = $(params.bannerId).optional.type(ID).$; if (bannerIdErr) return rej('invalid bannerId param'); if (bannerId) user.bannerId = bannerId; diff --git a/src/server/api/endpoints/i/update_client_setting.ts b/src/server/api/endpoints/i/update_client_setting.ts index b0d5db5ec2..f753c8bcc4 100644 --- a/src/server/api/endpoints/i/update_client_setting.ts +++ b/src/server/api/endpoints/i/update_client_setting.ts @@ -7,10 +7,6 @@ import event from '../../../../publishers/stream'; /** * Update myself - * - * @param {any} params - * @param {any} user - * @return {Promise<any>} */ module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'name' parameter diff --git a/src/server/api/endpoints/i/update_home.ts b/src/server/api/endpoints/i/update_home.ts index ce7661ede0..4b8ba25069 100644 --- a/src/server/api/endpoints/i/update_home.ts +++ b/src/server/api/endpoints/i/update_home.ts @@ -8,7 +8,7 @@ import event from '../../../../publishers/stream'; module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'home' parameter const [home, homeErr] = $(params.home).optional.array().each( - $().strict.object() + $().object(true) .have('name', $().string()) .have('id', $().string()) .have('place', $().string()) diff --git a/src/server/api/endpoints/i/update_mobile_home.ts b/src/server/api/endpoints/i/update_mobile_home.ts index b710e2f330..c3ecea7178 100644 --- a/src/server/api/endpoints/i/update_mobile_home.ts +++ b/src/server/api/endpoints/i/update_mobile_home.ts @@ -8,7 +8,7 @@ import event from '../../../../publishers/stream'; module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'home' parameter const [home, homeErr] = $(params.home).optional.array().each( - $().strict.object() + $().object(true) .have('name', $().string()) .have('id', $().string()) .have('data', $().object())).$; |