Add target kind tag to quote reposts

This commit is contained in:
thePR0M3TH3AN committed 2025-10-30 12:39:46 -04:00
1 parent 36bcbae0e9
commit ba656978a5
2 files changed
+47 -1

No files matched your search

+4
View File
@@ -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,
+43 -1
View File
@@ -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");
});