mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
fix(api): 🐛 Fix incorrect quote API serialization
This commit is contained in:
parent
db35ba6f93
commit
e8632caeac
|
|
@ -448,6 +448,16 @@ 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,
|
||||
|
|
@ -482,11 +492,7 @@ export class Note {
|
|||
pinned: wasPinnedByUser,
|
||||
// TODO: Add polls
|
||||
poll: null,
|
||||
reblog: data.reblog
|
||||
? await Note.fromStatus(
|
||||
data.reblog as StatusWithRelations,
|
||||
).toAPI(userFetching)
|
||||
: null,
|
||||
reblog: reblog ?? null,
|
||||
reblogged: wasRebloggedByUser,
|
||||
reblogs_count: data.reblogCount,
|
||||
replies_count: data.replyCount,
|
||||
|
|
@ -502,8 +508,7 @@ export class Note {
|
|||
visibility: data.visibility as APIStatus["visibility"],
|
||||
url: data.uri || this.getMastoURI(),
|
||||
bookmarked: false,
|
||||
// Set to null because this breaks Megalodon
|
||||
quote: false,
|
||||
quote: !!data.quotingId,
|
||||
// @ts-expect-error Pleroma extension
|
||||
quote_id: data.quotingId || undefined,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -294,6 +294,7 @@ 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);
|
||||
});
|
||||
|
||||
describe("mentions testing", () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue