From f74726456813a549aab6818fa040128d5d6c6c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Thu, 29 Aug 2024 23:05:23 +0200 Subject: [PATCH] fix quote_id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- packages/pl-api/lib/entities/status.ts | 7 +++++-- packages/pl-api/package.json | 2 +- packages/pl-fe/package.json | 2 +- packages/pl-fe/src/normalizers/status.ts | 2 +- packages/pl-fe/yarn.lock | 8 ++++---- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/pl-api/lib/entities/status.ts b/packages/pl-api/lib/entities/status.ts index 09eac3aa5..4512e8062 100644 --- a/packages/pl-api/lib/entities/status.ts +++ b/packages/pl-api/lib/entities/status.ts @@ -74,6 +74,7 @@ const baseStatusSchema = z.object({ group: groupSchema.nullable().catch(null), scheduled_at: z.null().catch(null), + quote_id: z.string().nullable().catch(null), local: z.boolean().optional().catch(undefined), conversation_id: z.string().optional().catch(undefined), direct_conversation_id: z.string().optional().catch(undefined), @@ -104,8 +105,10 @@ const baseStatusSchema = z.object({ const preprocess = (status: any) => { if (!status) return null; status = { + // @ts-ignore ...(pick(status.pleroma || {}, [ 'quote', + 'quote_id', 'local', 'conversation_id', 'direct_conversation_id', @@ -131,11 +134,11 @@ const preprocess = (status: any) => { return status; }; -const statusSchema: z.ZodType = baseStatusSchema.extend({ +const statusSchema: z.ZodType = z.preprocess(preprocess, baseStatusSchema.extend({ reblog: z.lazy(() => statusSchema).nullable().catch(null), quote: z.lazy(() => statusSchema).nullable().catch(null), -}) as any; +})) as any; const statusWithoutAccountSchema = z.preprocess(preprocess, baseStatusSchema.omit({ account: true }).extend({ account: accountSchema.nullable().catch(null), diff --git a/packages/pl-api/package.json b/packages/pl-api/package.json index 919732713..ed454ec89 100644 --- a/packages/pl-api/package.json +++ b/packages/pl-api/package.json @@ -1,6 +1,6 @@ { "name": "pl-api", - "version": "0.0.24", + "version": "0.0.25", "type": "module", "homepage": "https://github.com/mkljczk/pl-fe/tree/fork/packages/pl-api", "repository": { diff --git a/packages/pl-fe/package.json b/packages/pl-fe/package.json index a1ce6633b..d98a55f15 100644 --- a/packages/pl-fe/package.json +++ b/packages/pl-fe/package.json @@ -133,7 +133,7 @@ "multiselect-react-dropdown": "^2.0.25", "object-to-formdata": "^4.5.1", "path-browserify": "^1.0.1", - "pl-api": "^0.0.24", + "pl-api": "^0.0.25", "postcss": "^8.4.29", "process": "^0.11.10", "punycode": "^2.1.1", diff --git a/packages/pl-fe/src/normalizers/status.ts b/packages/pl-fe/src/normalizers/status.ts index 0cb32ec9a..75eb47452 100644 --- a/packages/pl-fe/src/normalizers/status.ts +++ b/packages/pl-fe/src/normalizers/status.ts @@ -151,12 +151,12 @@ const normalizeStatus = (status: BaseStatus & { account_id: status.account.id, reblog_id: status.reblog?.id || null, poll_id: status.poll?.id || null, - quote_id: status.quote?.id || null, group_id: status.group?.id || null, translating: false, expectsCard: false, showFiltered: null as null | boolean, ...status, + quote_id: status.quote?.id || status.quote_id || null, account: normalizeAccount(status.account), accounts: status.accounts?.map(normalizeAccount), mentions, diff --git a/packages/pl-fe/yarn.lock b/packages/pl-fe/yarn.lock index df65aeaa9..4a35f9c84 100644 --- a/packages/pl-fe/yarn.lock +++ b/packages/pl-fe/yarn.lock @@ -8385,10 +8385,10 @@ pkg-types@^1.0.3: mlly "^1.2.0" pathe "^1.1.0" -pl-api@^0.0.24: - version "0.0.24" - resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.0.24.tgz#f7c5798d4f04d2e9df4c20f264180035c9afabe0" - integrity sha512-Pa4bpsm0H90pUKJG3gm2eH7YUv7KkiK8s7Jxm3eM78ZQ7ysyR/5z8oev+82EhmvDsiPKkKjJwUFK+kfpO69pvw== +pl-api@^0.0.25: + version "0.0.25" + resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.0.25.tgz#d950d902c4bfe268d9de66611372dbd589939ca4" + integrity sha512-gBS/5aN47w0ZcE7I0gBQMkngMwB9DSHvH40dM5XsZGPzUw7f3VECHM+tZyTlZI13rdVC9xJlVQTPX1h9KmGUOg== dependencies: blurhash "^2.0.5" http-link-header "^1.1.3"