From ba656978a5db23207956357006462ae045db2793 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Thu, 30 Oct 2025 12:39:46 -0400 Subject: [PATCH] Add target kind tag to quote reposts --- js/nostrEventSchemas.js | 4 +++ tests/nostr/publishHelpers.test.mjs | 44 ++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/js/nostrEventSchemas.js b/js/nostrEventSchemas.js index 970fd11a..730a94bb 100644 --- a/js/nostrEventSchemas.js +++ b/js/nostrEventSchemas.js @@ -716,6 +716,10 @@ export function buildRepostEvent({ return schema?.kind ?? 6; })(); + if (resolvedKind === 16 && normalizedTargetKind !== null) { + tags.push(["k", String(normalizedTargetKind)]); + } + return { kind: resolvedKind, pubkey, diff --git a/tests/nostr/publishHelpers.test.mjs b/tests/nostr/publishHelpers.test.mjs index 164c56a1..af172fc8 100644 --- a/tests/nostr/publishHelpers.test.mjs +++ b/tests/nostr/publishHelpers.test.mjs @@ -1,7 +1,9 @@ import assert from "node:assert/strict"; import test from "node:test"; -const { mirrorVideoEvent } = await import("../../js/nostr/publishHelpers.js"); +const { mirrorVideoEvent, repostEvent } = await import( + "../../js/nostr/publishHelpers.js", +); const resolveActiveSignerStub = () => ({ signEvent: async (event) => ({ @@ -107,3 +109,43 @@ test("mirrorVideoEvent lowercases inferred MIME types", async () => { assert.ok(mTag, "mirror events must include a MIME tag"); assert.equal(mTag[1], "video/webm"); }); + +test("repostEvent adds a target kind tag for quote reposts", async () => { + const eventId = "quote-repost"; + const actorPubkey = "3".repeat(64); + const authorPubkey = "4".repeat(64); + const { client } = createPublishClient({ actorPubkey }); + + client.allEvents.set(eventId, { + kind: 30078, + pubkey: authorPubkey, + videoRootId: "video-root", + }); + client.rawEvents.set(eventId, { + kind: 30078, + pubkey: authorPubkey, + tags: [["d", "video-root"]], + }); + + const result = await repostEvent({ + client, + eventId, + options: { + actorPubkey, + authorPubkey, + kind: 30078, + }, + resolveActiveSigner: resolveActiveSignerStub, + shouldRequestExtensionPermissions: shouldRequestExtensionPermissionsStub, + signEventWithPrivateKey: signEventWithPrivateKeyStub, + eventToAddressPointer: () => "", + }); + + assert.equal(result.ok, true); + assert.equal(result.event?.kind, 16); + const kTag = result.event?.tags?.find( + (tag) => Array.isArray(tag) && tag[0] === "k", + ); + assert.ok(kTag, "repost events must include a target kind tag"); + assert.equal(kTag[1], "30078"); +});