misskey/src/server/api/endpoints/users/lists/show.ts
syuilo 0463c6bb0f
Refactor API (#4770)
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update description.ts

* wip
2019-04-23 22:35:26 +09:00

54 lines
1.0 KiB
TypeScript

import $ from 'cafy';
import { ID } from '../../../../../misc/cafy-id';
import define from '../../../define';
import { ApiError } from '../../../error';
import { UserLists } from '../../../../../models';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
desc: {
'ja-JP': '指定したユーザーリストの情報を取得します。',
'en-US': 'Show a user list.'
},
tags: ['lists', 'account'],
requireCredential: true,
kind: 'read:account',
params: {
listId: {
validator: $.type(ID),
},
},
res: {
type: types.object,
optional: bool.false, nullable: bool.false,
ref: 'UserList',
},
errors: {
noSuchList: {
message: 'No such list.',
code: 'NO_SUCH_LIST',
id: '7bc05c21-1d7a-41ae-88f1-66820f4dc686'
},
}
};
export default define(meta, async (ps, me) => {
// Fetch the list
const userList = await UserLists.findOne({
id: ps.listId,
userId: me.id,
});
if (userList == null) {
throw new ApiError(meta.errors.noSuchList);
}
return await UserLists.pack(userList);
});