From 457bd6c2e52ecdc48ca0a35318c164ca511fcb62 Mon Sep 17 00:00:00 2001 From: PrivateGER Date: Tue, 18 Jul 2023 16:00:48 +0200 Subject: [PATCH] Fix broken lists --- .../src/server/api/endpoints/users/lists/push.ts | 12 +++++------- .../src/server/api/endpoints/users/lists/show.ts | 10 ++++------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/users/lists/push.ts b/packages/backend/src/server/api/endpoints/users/lists/push.ts index 6f3e09fcb..899754aaf 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/push.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/push.ts @@ -52,14 +52,12 @@ export const paramDef = { export default define(meta, paramDef, async (ps, me) => { // Fetch the list - const listExists = await UserLists.exist({ - where: { - id: ps.listId, - userId: me.id, - }, + const userList = await UserLists.findOneBy({ + id: ps.listId, + userId: me.id, }); - if (!listExists) { + if (!userList) { throw new ApiError(meta.errors.noSuchList); } @@ -85,7 +83,7 @@ export default define(meta, paramDef, async (ps, me) => { const exist = await UserListJoinings.exist({ where: { - userListId: userList.id, + userListId: ps.listId, userId: user.id, }, }); diff --git a/packages/backend/src/server/api/endpoints/users/lists/show.ts b/packages/backend/src/server/api/endpoints/users/lists/show.ts index 8479a4e03..cb4893b0e 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/show.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/show.ts @@ -37,14 +37,12 @@ export const paramDef = { export default define(meta, paramDef, async (ps, me) => { // Fetch the list - const exist = await UserLists.exist({ - where: { - id: ps.listId, - userId: me.id, - }, + const userList = await UserLists.findOneBy({ + id: ps.listId, + userId: me.id, }); - if (!exist) { + if (!userList) { throw new ApiError(meta.errors.noSuchList); }