fix quote_id

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-08-29 23:05:23 +02:00
parent d91b55d9b1
commit f747264568
5 changed files with 12 additions and 9 deletions

View file

@ -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<Status> = baseStatusSchema.extend({
const statusSchema: z.ZodType<Status> = 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),

View file

@ -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": {

View file

@ -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",

View file

@ -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,

View file

@ -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"