Refactoring, Clean up and bug fixes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import $ from 'cafy'; import ID from '../../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../../misc/cafy-id';
|
||||
import UserList, { pack } from '../../../../../models/user-list';
|
||||
import { ILocalUser } from '../../../../../models/user';
|
||||
import getParams from '../../../get-params';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
@@ -10,17 +11,23 @@ export const meta = {
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
kind: 'account-read'
|
||||
kind: 'account-read',
|
||||
|
||||
params: {
|
||||
listId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
export default async (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
|
||||
// Get 'listId' parameter
|
||||
const [listId, listIdErr] = $.type(ID).get(params.listId);
|
||||
if (listIdErr) return rej('invalid listId param');
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) return rej(psErr);
|
||||
|
||||
// Fetch the list
|
||||
const userList = await UserList.findOne({
|
||||
_id: listId,
|
||||
_id: ps.listId,
|
||||
userId: me._id,
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user