diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-04-11 17:40:01 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-04-11 17:40:01 +0900 |
| commit | bd3d57a67f6d7c6a01516410d2322e6ffbd2f5ad (patch) | |
| tree | e5caa46997f78a61fb09a821aa0ac210784500fb /src/server/api/endpoints/app | |
| parent | v4771 (diff) | |
| download | sharkey-bd3d57a67f6d7c6a01516410d2322e6ffbd2f5ad.tar.gz sharkey-bd3d57a67f6d7c6a01516410d2322e6ffbd2f5ad.tar.bz2 sharkey-bd3d57a67f6d7c6a01516410d2322e6ffbd2f5ad.zip | |
ストリーム経由でAPIにリクエストできるように
Diffstat (limited to 'src/server/api/endpoints/app')
| -rw-r--r-- | src/server/api/endpoints/app/show.ts | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/server/api/endpoints/app/show.ts b/src/server/api/endpoints/app/show.ts index 3a3c25f47c..99a2093b68 100644 --- a/src/server/api/endpoints/app/show.ts +++ b/src/server/api/endpoints/app/show.ts @@ -36,14 +36,10 @@ import App, { pack } from '../../../../models/app'; /** * Show an app - * - * @param {any} params - * @param {any} user - * @param {any} _ - * @param {any} isSecure - * @return {Promise<any>} */ -module.exports = (params, user, _, isSecure) => new Promise(async (res, rej) => { +module.exports = (params, user, app) => new Promise(async (res, rej) => { + const isSecure = user != null && app == null; + // Get 'appId' parameter const [appId, appIdErr] = $(params.appId).optional.id().$; if (appIdErr) return rej('invalid appId param'); @@ -57,16 +53,16 @@ module.exports = (params, user, _, isSecure) => new Promise(async (res, rej) => } // Lookup app - const app = appId !== undefined + const ap = appId !== undefined ? await App.findOne({ _id: appId }) : await App.findOne({ nameIdLower: nameId.toLowerCase() }); - if (app === null) { + if (ap === null) { return rej('app not found'); } // Send response - res(await pack(app, user, { - includeSecret: isSecure && app.userId.equals(user._id) + res(await pack(ap, user, { + includeSecret: isSecure && ap.userId.equals(user._id) })); }); |