summaryrefslogtreecommitdiff
path: root/src/api/endpoints/i/appdata/get.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/endpoints/i/appdata/get.ts')
-rw-r--r--src/api/endpoints/i/appdata/get.ts45
1 files changed, 17 insertions, 28 deletions
diff --git a/src/api/endpoints/i/appdata/get.ts b/src/api/endpoints/i/appdata/get.ts
index a1a57fa13a..571208d46c 100644
--- a/src/api/endpoints/i/appdata/get.ts
+++ b/src/api/endpoints/i/appdata/get.ts
@@ -13,38 +13,27 @@ import Appdata from '../../../models/appdata';
* @param {Boolean} isSecure
* @return {Promise<any>}
*/
-module.exports = (params, user, app, isSecure) => new Promise(async (res, rej) => {
+module.exports = (params, user, app) => new Promise(async (res, rej) => {
+ if (app == null) return rej('このAPIはサードパーティAppからのみ利用できます');
+
// Get 'key' parameter
const [key = null, keyError] = $(params.key).optional.nullable.string().match(/[a-z_]+/).$;
if (keyError) return rej('invalid key param');
- if (isSecure) {
- if (!user.data) {
- return res();
- }
- if (key !== null) {
- const data = {};
- data[key] = user.data[key];
- res(data);
- } else {
- res(user.data);
- }
- } else {
- const select = {};
- if (key !== null) {
- select[`data.${key}`] = true;
- }
- const appdata = await Appdata.findOne({
- app_id: app._id,
- user_id: user._id
- }, {
- fields: select
- });
+ const select = {};
+ if (key !== null) {
+ select[`data.${key}`] = true;
+ }
+ const appdata = await Appdata.findOne({
+ app_id: app._id,
+ user_id: user._id
+ }, {
+ fields: select
+ });
- if (appdata) {
- res(appdata.data);
- } else {
- res();
- }
+ if (appdata) {
+ res(appdata.data);
+ } else {
+ res();
}
});