From 174ee0242e070e12e615857713cfacc6197a3bb1 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Wed, 29 Oct 2025 21:53:06 -0400 Subject: [PATCH] Fix NIP-56 report tag ordering --- js/services/moderationService.js | 3 +-- tests/moderation/submit-report.test.mjs | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/js/services/moderationService.js b/js/services/moderationService.js index efe0d923..338c89df 100644 --- a/js/services/moderationService.js +++ b/js/services/moderationService.js @@ -2153,11 +2153,10 @@ export class ModerationService { const sanitizedRelayHint = typeof relayHint === "string" ? relayHint.trim() : ""; - const eventTag = ["e", normalizedEventId]; + const eventTag = ["e", normalizedEventId, normalizedType]; if (sanitizedRelayHint) { eventTag.push(sanitizedRelayHint); } - eventTag.push(normalizedType); const tags = [ eventTag, diff --git a/tests/moderation/submit-report.test.mjs b/tests/moderation/submit-report.test.mjs index a4c53390..560b4a96 100644 --- a/tests/moderation/submit-report.test.mjs +++ b/tests/moderation/submit-report.test.mjs @@ -66,7 +66,11 @@ test("submitReport emits NIP-56 compliant report tags", async (t) => { assert.equal(ok, true, "submitReport should resolve with ok: true"); const eTag = event.tags.find((tag) => Array.isArray(tag) && tag[0] === "e"); - assert.deepEqual(eTag, ["e", eventId, relayHint, "malware"], "e tag should include relay hint before type"); + assert.deepEqual( + eTag, + ["e", eventId, "malware", relayHint], + "e tag should include type before relay hint", + ); const pTag = event.tags.find((tag) => Array.isArray(tag) && tag[0] === "p"); assert.deepEqual(pTag, ["p", targetPubkey, "malware"], "p tag should include reported author and type"); @@ -88,7 +92,7 @@ test("submitReport emits NIP-56 compliant report tags", async (t) => { assert.deepEqual( followupETag, ["e", followupId, "spam"], - "e tag without relay hint should collapse to type as third entry", + "e tag without relay hint should place type as third entry", ); assert.ok(publishCalls.length >= 2, "submitReport should publish each report");