summaryrefslogtreecommitdiff
path: root/src/api/serializers/app.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-02-02 08:06:01 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-02-02 08:06:01 +0900
commit9a282e37be5ba847718d198d30eb97f31d11f2a0 (patch)
tree9e1f6bda799ca3f6cc6b489a96751cb5b48f170b /src/api/serializers/app.ts
parentUpdate dependencies :rocket: (diff)
downloadmisskey-9a282e37be5ba847718d198d30eb97f31d11f2a0.tar.gz
misskey-9a282e37be5ba847718d198d30eb97f31d11f2a0.tar.bz2
misskey-9a282e37be5ba847718d198d30eb97f31d11f2a0.zip
wip
Diffstat (limited to 'src/api/serializers/app.ts')
-rw-r--r--src/api/serializers/app.ts83
1 files changed, 0 insertions, 83 deletions
diff --git a/src/api/serializers/app.ts b/src/api/serializers/app.ts
deleted file mode 100644
index 9d1c46dca4..0000000000
--- a/src/api/serializers/app.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Module dependencies
- */
-import * as mongo from 'mongodb';
-import deepcopy = require('deepcopy');
-import App from '../models/app';
-import AccessToken from '../models/access-token';
-import config from '../../conf';
-
-/**
- * Serialize an app
- *
- * @param {any} app
- * @param {any} me?
- * @param {any} options?
- * @return {Promise<any>}
- */
-export default (
- app: any,
- me?: any,
- options?: {
- includeSecret?: boolean,
- includeProfileImageIds?: boolean
- }
-) => new Promise<any>(async (resolve, reject) => {
- const opts = options || {
- includeSecret: false,
- includeProfileImageIds: false
- };
-
- let _app: any;
-
- // Populate the app if 'app' is ID
- if (mongo.ObjectID.prototype.isPrototypeOf(app)) {
- _app = await App.findOne({
- _id: app
- });
- } else if (typeof app === 'string') {
- _app = await App.findOne({
- _id: new mongo.ObjectID(app)
- });
- } else {
- _app = deepcopy(app);
- }
-
- // Me
- if (me && !mongo.ObjectID.prototype.isPrototypeOf(me)) {
- if (typeof me === 'string') {
- me = new mongo.ObjectID(me);
- } else {
- me = me._id;
- }
- }
-
- // Rename _id to id
- _app.id = _app._id;
- delete _app._id;
-
- delete _app.name_id_lower;
-
- // Visible by only owner
- if (!opts.includeSecret) {
- delete _app.secret;
- }
-
- _app.icon_url = _app.icon != null
- ? `${config.drive_url}/${_app.icon}`
- : `${config.drive_url}/app-default.jpg`;
-
- if (me) {
- // 既に連携しているか
- const exist = await AccessToken.count({
- app_id: _app.id,
- user_id: me,
- }, {
- limit: 1
- });
-
- _app.is_authorized = exist === 1;
- }
-
- resolve(_app);
-});