2018-09-02 12:59:42 +03:00
|
|
|
import $ from 'cafy';
|
2018-11-01 20:32:24 +02:00
|
|
|
import ID, { transform } from '../../../../../misc/cafy-id';
|
2018-10-29 14:06:23 +02:00
|
|
|
import UserList from '../../../../../models/user-list';
|
2018-11-02 06:47:44 +02:00
|
|
|
import define from '../../../define';
|
2018-09-02 12:59:42 +03:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
desc: {
|
|
|
|
'ja-JP': '指定したユーザーリストを削除します。',
|
|
|
|
'en-US': 'Delete a user list'
|
|
|
|
},
|
|
|
|
|
|
|
|
requireCredential: true,
|
|
|
|
|
|
|
|
kind: 'account-write',
|
|
|
|
|
|
|
|
params: {
|
2018-11-01 20:32:24 +02:00
|
|
|
listId: {
|
|
|
|
validator: $.type(ID),
|
|
|
|
transform: transform,
|
2018-09-02 12:59:42 +03:00
|
|
|
desc: {
|
|
|
|
'ja-JP': '対象となるユーザーリストのID',
|
|
|
|
'en-US': 'ID of target user list'
|
|
|
|
}
|
2018-11-01 20:32:24 +02:00
|
|
|
}
|
2018-09-02 12:59:42 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-11-02 06:47:44 +02:00
|
|
|
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
2018-09-02 12:59:42 +03:00
|
|
|
const userList = await UserList.findOne({
|
|
|
|
_id: ps.listId,
|
|
|
|
userId: user._id
|
|
|
|
});
|
|
|
|
|
|
|
|
if (userList == null) {
|
|
|
|
return rej('list not found');
|
|
|
|
}
|
|
|
|
|
2018-10-29 14:06:23 +02:00
|
|
|
await UserList.remove({
|
|
|
|
_id: userList._id
|
|
|
|
});
|
2018-09-02 12:59:42 +03:00
|
|
|
|
|
|
|
res();
|
2018-11-02 06:47:44 +02:00
|
|
|
}));
|