fix(api): 🐛 Fix quote serialization in API again

This commit is contained in:
Jesse Wierzbinski 2024-04-27 20:15:08 -10:00
parent e8632caeac
commit de0214c77e
No known key found for this signature in database
2 changed files with 13 additions and 14 deletions

View file

@ -448,16 +448,6 @@ export class Note {
);
}
const reblog = data.quotingId
? await Note.fromId(data.quotingId).then((n) =>
n?.toAPI(userFetching),
)
: data.reblog
? await Note.fromStatus(data.reblog as StatusWithRelations).toAPI(
userFetching,
)
: null;
return {
id: data.id,
in_reply_to_id: data.replyId || null,
@ -492,7 +482,11 @@ export class Note {
pinned: wasPinnedByUser,
// TODO: Add polls
poll: null,
reblog: reblog ?? null,
reblog: data.reblog
? await Note.fromStatus(
data.reblog as StatusWithRelations,
).toAPI(userFetching)
: null,
reblogged: wasRebloggedByUser,
reblogs_count: data.reblogCount,
replies_count: data.replyCount,
@ -508,8 +502,12 @@ export class Note {
visibility: data.visibility as APIStatus["visibility"],
url: data.uri || this.getMastoURI(),
bookmarked: false,
quote: !!data.quotingId,
// @ts-expect-error Pleroma extension
// @ts-expect-error Glitch-SOC extension
quote: data.quotingId
? (await Note.fromId(data.quotingId).then((n) =>
n?.toAPI(userFetching),
)) ?? null
: null,
quote_id: data.quotingId || undefined,
};
}

View file

@ -294,7 +294,8 @@ describe(meta.route, () => {
expect(object2.content).toBe("<p>Hello, world again!</p>");
// @ts-expect-error Pleroma extension
expect(object2.quote_id).toBe(object.id);
expect(object2.reblog?.id).toBe(object.id);
// @ts-expect-error Glitch SOC extension
expect(object2.quote?.id).toBe(object.id);
});
describe("mentions testing", () => {