From e9d443e89ab426b46d565f2e6aeb4f9edb6b133c Mon Sep 17 00:00:00 2001 From: wentokay <101902546+wentokay@users.noreply.github.com> Date: Mon, 20 Mar 2023 17:05:52 -0700 Subject: [PATCH] return empty array if userIds.length === 0 (#3424) --- backend/native/backend-ws/src/db/users.ts | 3 +++ backend/native/backpack-api/src/db/friendships.ts | 3 +++ backend/native/backpack-api/src/db/users.ts | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/backend/native/backend-ws/src/db/users.ts b/backend/native/backend-ws/src/db/users.ts index ca7386ef8..d21c92a5f 100644 --- a/backend/native/backend-ws/src/db/users.ts +++ b/backend/native/backend-ws/src/db/users.ts @@ -11,6 +11,9 @@ const chain = Chain(AUTH_HASURA_URL, { export const getUsers = async ( userIds: string[] ): Promise<{ id: string; username: string }[]> => { + // hotfix: empty array returns all records + if (userIds.filter(Boolean).length === 0) return []; + const response = await chain("query")( { auth_users: [ diff --git a/backend/native/backpack-api/src/db/friendships.ts b/backend/native/backpack-api/src/db/friendships.ts index 4e9a47e52..e91c9e54e 100644 --- a/backend/native/backpack-api/src/db/friendships.ts +++ b/backend/native/backpack-api/src/db/friendships.ts @@ -456,6 +456,9 @@ export const getFriendshipStatus = async ( remoteRequested: boolean; }[] > => { + // hotfix: empty array returns all records + if (userIds.filter(Boolean).length === 0) return []; + const response = await chain("query")( { auth_friendships: [ diff --git a/backend/native/backpack-api/src/db/users.ts b/backend/native/backpack-api/src/db/users.ts index 90332f1dc..5b85f3e37 100644 --- a/backend/native/backpack-api/src/db/users.ts +++ b/backend/native/backpack-api/src/db/users.ts @@ -21,6 +21,9 @@ export const getUsersMetadata = async ( id: unknown; }[] > => { + // hotfix: empty array returns all records + if (userIds.filter(Boolean).length === 0) return []; + const response = await chain("query")( { auth_users: [ @@ -50,6 +53,9 @@ export const getUsers = async ( publicKeys: unknown[]; }[] > => { + // hotfix: empty array returns all records + if (userIds.filter(Boolean).length === 0) return []; + const response = await chain("query")( { auth_users: [