pl-api: fix masto quotes

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2025-10-15 14:51:06 +02:00
parent 5bc3ef409e
commit e0b31a663a
3 changed files with 7 additions and 7 deletions

View File

@ -8,7 +8,7 @@ import { statusSchema } from './status';
*/
const quoteSchema = v.object({
state: v.fallback(v.picklist(['pending', 'accepted', 'rejected', 'revoked', 'deleted', 'unauthorized']), 'accepted'),
status: v.fallback(v.nullable(v.lazy(() => statusSchema)), null),
quoted_status: v.fallback(v.nullable(v.lazy(() => statusSchema)), null),
});
/**
@ -22,7 +22,7 @@ type Quote = v.InferOutput<typeof quoteSchema>;
*/
const shallowQuoteSchema = v.object({
state: v.fallback(v.picklist(['pending', 'accepted', 'rejected', 'revoked', 'deleted', 'unauthorized']), 'accepted'),
status_id: v.fallback(v.nullable(v.string()), null),
quoted_status_id: v.fallback(v.nullable(v.string()), null),
});
/**

View File

@ -114,10 +114,10 @@ const preprocess = (status: any) => {
let quote: {
state: string;
status: any;
quoted_status: any;
} | {
state: string;
status_id: string;
quoted_status_id: string;
} | null = null;
const quotedStatus = status.quote ?? status.pleroma?.quote;
@ -127,13 +127,13 @@ const preprocess = (status: any) => {
} else if (quotedStatus) {
quote = {
state: 'accepted',
status: quotedStatus,
quoted_status: quotedStatus,
};
} else {
if (quotedStatusId) {
quote = {
state: 'accepted',
status_id: quotedStatusId,
quoted_status_id: quotedStatusId,
};
}
}