Merge pull request '[PR]: Fix user lists' (#10515) from PrivateGER/calckey:fix/user-lists into develop

Reviewed-on: https://codeberg.org/calckey/calckey/pulls/10515
This commit is contained in:
Kainoa Kanter 2023-07-18 15:59:44 +00:00
commit 2b59d03d6f
2 changed files with 9 additions and 13 deletions

View file

@ -52,14 +52,12 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, me) => { export default define(meta, paramDef, async (ps, me) => {
// Fetch the list // Fetch the list
const listExists = await UserLists.exist({ const userList = await UserLists.findOneBy({
where: {
id: ps.listId, id: ps.listId,
userId: me.id, userId: me.id,
},
}); });
if (!listExists) { if (!userList) {
throw new ApiError(meta.errors.noSuchList); throw new ApiError(meta.errors.noSuchList);
} }
@ -85,7 +83,7 @@ export default define(meta, paramDef, async (ps, me) => {
const exist = await UserListJoinings.exist({ const exist = await UserListJoinings.exist({
where: { where: {
userListId: userList.id, userListId: ps.listId,
userId: user.id, userId: user.id,
}, },
}); });

View file

@ -37,14 +37,12 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, me) => { export default define(meta, paramDef, async (ps, me) => {
// Fetch the list // Fetch the list
const exist = await UserLists.exist({ const userList = await UserLists.findOneBy({
where: {
id: ps.listId, id: ps.listId,
userId: me.id, userId: me.id,
},
}); });
if (!exist) { if (!userList) {
throw new ApiError(meta.errors.noSuchList); throw new ApiError(meta.errors.noSuchList);
} }