Files
misskey/src/server/api/endpoints/users/lists/create.ts
syuilo ce340aba7a Refactor (#7394)
* wip

* wip

* wip

* wip

* wip

* Update define.ts

* Update update.ts

* Update user.ts

* wip

* wip

* Update request.ts

* URL

* wip

* wip

* wip

* wip

* Update invite.ts

* Update create.ts
2021-03-24 11:05:37 +09:00

42 lines
889 B
TypeScript

import $ from 'cafy';
import define from '../../../define';
import { UserLists } from '../../../../../models';
import { genId } from '@/misc/gen-id';
import { UserList } from '../../../../../models/entities/user-list';
export const meta = {
desc: {
'ja-JP': 'ユーザーリストを作成します。',
'en-US': 'Create a user list'
},
tags: ['lists'],
requireCredential: true as const,
kind: 'write:account',
params: {
name: {
validator: $.str.range(1, 100)
}
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'UserList',
},
};
export default define(meta, async (ps, user) => {
const userList = await UserLists.insert({
id: genId(),
createdAt: new Date(),
userId: user.id,
name: ps.name,
} as UserList).then(x => UserLists.findOneOrFail(x.identifiers[0]));
return await UserLists.pack(userList);
});