mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-12-03 01:08:05 +09:00
[mastodon-client] Only encode renote once in NoteConverter
This commit is contained in:
parent
23a1114c02
commit
b3c186a14a
@ -61,7 +61,7 @@ export class NoteConverter {
|
|||||||
}
|
}
|
||||||
}) : null;
|
}) : null;
|
||||||
|
|
||||||
const renote = note.renote ?? (note.renoteId ? getNote(note.renoteId, user) : null);
|
const renote = note.renote ?? (note.renoteId && recurse ? getNote(note.renoteId, user) : null);
|
||||||
|
|
||||||
const isBookmarked = user ? NoteFavorites.exist({
|
const isBookmarked = user ? NoteFavorites.exist({
|
||||||
where: {
|
where: {
|
||||||
@ -103,6 +103,8 @@ export class NoteConverter {
|
|||||||
} as MastodonEntity.Tag;
|
} as MastodonEntity.Tag;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const reblog = Promise.resolve(renote).then(renote => recurse && renote ? this.encode(renote, ctx, false) : null);
|
||||||
|
|
||||||
// noinspection ES6MissingAwait
|
// noinspection ES6MissingAwait
|
||||||
return await awaitAll({
|
return await awaitAll({
|
||||||
id: note.id,
|
id: note.id,
|
||||||
@ -111,7 +113,7 @@ export class NoteConverter {
|
|||||||
account: Promise.resolve(noteUser).then(p => UserConverter.encode(p, ctx)),
|
account: Promise.resolve(noteUser).then(p => UserConverter.encode(p, ctx)),
|
||||||
in_reply_to_id: note.replyId,
|
in_reply_to_id: note.replyId,
|
||||||
in_reply_to_account_id: note.replyUserId,
|
in_reply_to_account_id: note.replyUserId,
|
||||||
reblog: Promise.resolve(renote).then(renote => recurse && renote && note.text === null ? this.encode(renote, ctx, false) : null),
|
reblog: reblog.then(reblog => note.text === null ? reblog : null),
|
||||||
content: text.then(text => text !== null ? MfmHelpers.toHtml(mfm.parse(text), JSON.parse(note.mentionedRemoteUsers)) ?? escapeMFM(text) : ""),
|
content: text.then(text => text !== null ? MfmHelpers.toHtml(mfm.parse(text), JSON.parse(note.mentionedRemoteUsers)) ?? escapeMFM(text) : ""),
|
||||||
text: text,
|
text: text,
|
||||||
created_at: note.createdAt.toISOString(),
|
created_at: note.createdAt.toISOString(),
|
||||||
@ -135,7 +137,7 @@ export class NoteConverter {
|
|||||||
pinned: isPinned,
|
pinned: isPinned,
|
||||||
reactions: populated.then(populated => Promise.resolve(reaction).then(reaction => this.encodeReactions(note.reactions, reaction?.reaction, populated))),
|
reactions: populated.then(populated => Promise.resolve(reaction).then(reaction => this.encodeReactions(note.reactions, reaction?.reaction, populated))),
|
||||||
bookmarked: isBookmarked,
|
bookmarked: isBookmarked,
|
||||||
quote: Promise.resolve(renote).then(renote => recurse && renote && note.text !== null ? this.encode(renote, ctx, false) : null),
|
quote: reblog.then(reblog => note.text !== null ? reblog : null),
|
||||||
edited_at: note.updatedAt?.toISOString()
|
edited_at: note.updatedAt?.toISOString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user