mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 20:53:08 +02:00
29 lines
653 B
TypeScript
29 lines
653 B
TypeScript
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
|
import App, { pack } from '../../../../models/app';
|
|
import define from '../../define';
|
|
|
|
export const meta = {
|
|
params: {
|
|
appId: {
|
|
validator: $.type(ID),
|
|
transform: transform
|
|
},
|
|
}
|
|
};
|
|
|
|
export default define(meta, (ps, user, app) => new Promise(async (res, rej) => {
|
|
const isSecure = user != null && app == null;
|
|
|
|
// Lookup app
|
|
const ap = await App.findOne({ _id: ps.appId });
|
|
|
|
if (ap === null) {
|
|
return rej('app not found');
|
|
}
|
|
|
|
// Send response
|
|
res(await pack(ap, user, {
|
|
detail: true,
|
|
includeSecret: isSecure && ap.userId.equals(user._id)
|
|
}));
|
|
}));
|