pl-api: fix masto quotes
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -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),
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ const importEntities = (entities: {
|
||||
processAccount(status.account);
|
||||
}
|
||||
|
||||
if (status.quote && 'status' in status.quote && status.quote.status) processStatus(status.quote.status);
|
||||
if (status.quote && 'quoted_status' in status.quote && status.quote.quoted_status) processStatus(status.quote.quoted_status);
|
||||
if (status.reblog) processStatus(status.reblog);
|
||||
if (status.poll) polls[status.poll.id] = status.poll;
|
||||
if (status.group) groups[status.group.id] = status.group;
|
||||
|
||||
Reference in New Issue
Block a user