From e6fb39dc8453bf95942305e8e69aa035062448cf Mon Sep 17 00:00:00 2001 From: Daniel Holmgren Date: Thu, 16 Nov 2023 12:27:46 -0600 Subject: [PATCH] Bugfix: fetchLabels (#1862) * fix fetch labels * tidy * update cast to parseInt --- packages/bsky/src/api/com/atproto/temp/fetchLabels.ts | 7 ++++++- packages/xrpc-server/src/util.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/bsky/src/api/com/atproto/temp/fetchLabels.ts b/packages/bsky/src/api/com/atproto/temp/fetchLabels.ts index 77addd24cc1..8a6cacc2fbd 100644 --- a/packages/bsky/src/api/com/atproto/temp/fetchLabels.ts +++ b/packages/bsky/src/api/com/atproto/temp/fetchLabels.ts @@ -7,7 +7,7 @@ export default function (server: Server, ctx: AppContext) { const db = ctx.db.getReplica() const since = params.since !== undefined ? new Date(params.since).toISOString() : '' - const labels = await db.db + const labelRes = await db.db .selectFrom('label') .selectAll() .orderBy('label.cts', 'asc') @@ -15,6 +15,11 @@ export default function (server: Server, ctx: AppContext) { .limit(limit) .execute() + const labels = labelRes.map((l) => ({ + ...l, + cid: l.cid === '' ? undefined : l.cid, + })) + return { encoding: 'application/json', body: { diff --git a/packages/xrpc-server/src/util.ts b/packages/xrpc-server/src/util.ts index 730db950fbd..f306d1944aa 100644 --- a/packages/xrpc-server/src/util.ts +++ b/packages/xrpc-server/src/util.ts @@ -60,7 +60,7 @@ export function decodeQueryParam( if (type === 'float') { return Number(String(value)) } else if (type === 'integer') { - return Number(String(value)) | 0 + return parseInt(String(value), 10) || 0 } else if (type === 'boolean') { return value === 'true' }