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,
|
me?: { id: MiUser['id'] } | null | undefined,
|
||||||
options?: {
|
options?: {
|
||||||
detail?: boolean;
|
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;
|
skipHide?: boolean;
|
||||||
withReactionAndUserPairCache?: boolean;
|
withReactionAndUserPairCache?: boolean;
|
||||||
bypassSilence?: boolean;
|
bypassSilence?: boolean;
|
||||||
|
|
@ -535,6 +537,8 @@ export class NoteEntityService implements OnModuleInit {
|
||||||
skipHide: false,
|
skipHide: false,
|
||||||
withReactionAndUserPairCache: false,
|
withReactionAndUserPairCache: false,
|
||||||
}, options);
|
}, options);
|
||||||
|
opts.recurseRenote ??= opts.detail;
|
||||||
|
opts.recurseReply ??= opts.detail;
|
||||||
|
|
||||||
const meId = me ? me.id : null;
|
const meId = me ? me.id : null;
|
||||||
const note = typeof src === 'object' ? src : await this.noteLoader.load(src);
|
const note = typeof src === 'object' ? src : await this.noteLoader.load(src);
|
||||||
|
|
@ -647,8 +651,9 @@ export class NoteEntityService implements OnModuleInit {
|
||||||
...(opts.detail ? {
|
...(opts.detail ? {
|
||||||
clippedCount: note.clippedCount,
|
clippedCount: note.clippedCount,
|
||||||
processErrors: note.processErrors,
|
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,
|
detail: false,
|
||||||
skipHide: opts.skipHide,
|
skipHide: opts.skipHide,
|
||||||
withReactionAndUserPairCache: opts.withReactionAndUserPairCache,
|
withReactionAndUserPairCache: opts.withReactionAndUserPairCache,
|
||||||
|
|
@ -658,8 +663,11 @@ export class NoteEntityService implements OnModuleInit {
|
||||||
bypassSilence: bypassSilence || note.userId === note.replyUserId,
|
bypassSilence: bypassSilence || note.userId === note.replyUserId,
|
||||||
}) : undefined,
|
}) : undefined,
|
||||||
|
|
||||||
renote: note.renoteId ? this.pack(note.renote ?? opts._hint_?.notes.get(note.renoteId) ?? note.renoteId, me, {
|
// The renote target needs to be packed with the reply, but we *must not* recurse any further.
|
||||||
detail: true,
|
// 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,
|
skipHide: opts.skipHide,
|
||||||
withReactionAndUserPairCache: opts.withReactionAndUserPairCache,
|
withReactionAndUserPairCache: opts.withReactionAndUserPairCache,
|
||||||
_hint_: options?._hint_,
|
_hint_: options?._hint_,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue