prevent packing renotes at infinite depth
This commit is contained in:
parent
74a7f96cc2
commit
c2e52f6ae7
1 changed files with 11 additions and 3 deletions
|
|
@ -508,6 +508,8 @@ export class NoteEntityService implements OnModuleInit {
|
|||
me?: { id: MiUser['id'] } | null | undefined,
|
||||
options?: {
|
||||
detail?: boolean;
|
||||
recurseReply?: boolean; // Defaults to the value of detail, which defaults to true.
|
||||
recurseRenote?: boolean; // Defaults to the value of detail, which defaults to true.
|
||||
skipHide?: boolean;
|
||||
withReactionAndUserPairCache?: boolean;
|
||||
bypassSilence?: boolean;
|
||||
|
|
@ -535,6 +537,8 @@ export class NoteEntityService implements OnModuleInit {
|
|||
skipHide: false,
|
||||
withReactionAndUserPairCache: false,
|
||||
}, options);
|
||||
opts.recurseRenote ??= opts.detail;
|
||||
opts.recurseReply ??= opts.detail;
|
||||
|
||||
const meId = me ? me.id : null;
|
||||
const note = typeof src === 'object' ? src : await this.noteLoader.load(src);
|
||||
|
|
@ -647,8 +651,9 @@ export class NoteEntityService implements OnModuleInit {
|
|||
...(opts.detail ? {
|
||||
clippedCount: note.clippedCount,
|
||||
processErrors: note.processErrors,
|
||||
} : {}),
|
||||
|
||||
reply: note.replyId ? this.pack(note.reply ?? opts._hint_?.notes.get(note.replyId) ?? note.replyId, me, {
|
||||
reply: opts.recurseReply && note.replyId ? this.pack(note.reply ?? opts._hint_?.notes.get(note.replyId) ?? note.replyId, me, {
|
||||
detail: false,
|
||||
skipHide: opts.skipHide,
|
||||
withReactionAndUserPairCache: opts.withReactionAndUserPairCache,
|
||||
|
|
@ -658,8 +663,11 @@ export class NoteEntityService implements OnModuleInit {
|
|||
bypassSilence: bypassSilence || note.userId === note.replyUserId,
|
||||
}) : undefined,
|
||||
|
||||
renote: note.renoteId ? this.pack(note.renote ?? opts._hint_?.notes.get(note.renoteId) ?? note.renoteId, me, {
|
||||
detail: true,
|
||||
// The renote target needs to be packed with the reply, but we *must not* recurse any further.
|
||||
// Pass detail=false and recurseReply=true to make sure we only include the right data.
|
||||
renote: opts.recurseRenote && note.renoteId ? this.pack(note.renote ?? opts._hint_?.notes.get(note.renoteId) ?? note.renoteId, me, {
|
||||
detail: false,
|
||||
recurseReply: true,
|
||||
skipHide: opts.skipHide,
|
||||
withReactionAndUserPairCache: opts.withReactionAndUserPairCache,
|
||||
_hint_: options?._hint_,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue