mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38: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 {
|
return {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
in_reply_to_id: data.replyId || null,
|
in_reply_to_id: data.replyId || null,
|
||||||
|
|
@ -482,11 +492,7 @@ export class Note {
|
||||||
pinned: wasPinnedByUser,
|
pinned: wasPinnedByUser,
|
||||||
// TODO: Add polls
|
// TODO: Add polls
|
||||||
poll: null,
|
poll: null,
|
||||||
reblog: data.reblog
|
reblog: reblog ?? null,
|
||||||
? await Note.fromStatus(
|
|
||||||
data.reblog as StatusWithRelations,
|
|
||||||
).toAPI(userFetching)
|
|
||||||
: null,
|
|
||||||
reblogged: wasRebloggedByUser,
|
reblogged: wasRebloggedByUser,
|
||||||
reblogs_count: data.reblogCount,
|
reblogs_count: data.reblogCount,
|
||||||
replies_count: data.replyCount,
|
replies_count: data.replyCount,
|
||||||
|
|
@ -502,8 +508,7 @@ export class Note {
|
||||||
visibility: data.visibility as APIStatus["visibility"],
|
visibility: data.visibility as APIStatus["visibility"],
|
||||||
url: data.uri || this.getMastoURI(),
|
url: data.uri || this.getMastoURI(),
|
||||||
bookmarked: false,
|
bookmarked: false,
|
||||||
// Set to null because this breaks Megalodon
|
quote: !!data.quotingId,
|
||||||
quote: false,
|
|
||||||
// @ts-expect-error Pleroma extension
|
// @ts-expect-error Pleroma extension
|
||||||
quote_id: data.quotingId || undefined,
|
quote_id: data.quotingId || undefined,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,7 @@ describe(meta.route, () => {
|
||||||
expect(object2.content).toBe("<p>Hello, world again!</p>");
|
expect(object2.content).toBe("<p>Hello, world again!</p>");
|
||||||
// @ts-expect-error Pleroma extension
|
// @ts-expect-error Pleroma extension
|
||||||
expect(object2.quote_id).toBe(object.id);
|
expect(object2.quote_id).toBe(object.id);
|
||||||
|
expect(object2.reblog?.id).toBe(object.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("mentions testing", () => {
|
describe("mentions testing", () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue