Skip to content

Commit 764e68d

Browse files
committed
Make recursive target mapping explicit for quote properties
Handle quote recursion properties explicitly in getRecursiveTargetId instead of relying on an implicit non-reply fallback. This keeps the mapping self-documenting and returns null for unexpected values. Also adds a regression test that verifies unknown recurse properties fall back to null. #608 (comment)
1 parent 95423d9 commit 764e68d

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

packages/cli/src/lookup.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,23 @@ for (
601601
});
602602
}
603603

604+
test("getRecursiveTargetId - returns null for unknown recurse property", () => {
605+
const quoteUrl = new URL("https://example.com/notes/quoted");
606+
const note = new Note({
607+
id: new URL("https://example.com/notes/1"),
608+
quoteUrl,
609+
});
610+
assert.equal(
611+
getRecursiveTargetId(
612+
note,
613+
"https://example.com/custom#prop" as Parameters<
614+
typeof getRecursiveTargetId
615+
>[1],
616+
),
617+
null,
618+
);
619+
});
620+
604621
test("collectRecursiveObjects - follows chain up to depth limit", async () => {
605622
const note1 = new Note({
606623
id: new URL("https://example.com/notes/1"),

packages/cli/src/lookup.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,15 @@ export function getRecursiveTargetId(
503503
) {
504504
return object.replyTargetId;
505505
}
506-
const quoteUrl = (object as { quoteUrl?: unknown }).quoteUrl;
507-
return quoteUrl instanceof URL ? quoteUrl : null;
506+
if (
507+
recurseProperty === "quoteUrl" || recurseProperty === QUOTE_URL_IRI ||
508+
recurseProperty === MISSKEY_QUOTE_IRI ||
509+
recurseProperty === FEDIBIRD_QUOTE_IRI
510+
) {
511+
const quoteUrl = (object as { quoteUrl?: unknown }).quoteUrl;
512+
return quoteUrl instanceof URL ? quoteUrl : null;
513+
}
514+
return null;
508515
}
509516

510517
/**

0 commit comments

Comments
 (0)