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