From 4f798759dd648d05675061875a555db6321fcdc6 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 15 Jul 2026 02:17:47 +0900 Subject: [PATCH] publish: reference the parent comment with an e tag when commenting under an external-content (I) thread, instead of pointing at the root i again. --- publish.go | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/publish.go b/publish.go index 601fd42..164a736 100644 --- a/publish.go +++ b/publish.go @@ -280,30 +280,22 @@ func buildNIP22Tags(evt *nostr.Event, target *nostr.Event, relayHints []string) } // parent tags (lowercase) - always reference the target event - if rootScopeName == "I" { - iTag := nostr.Tag{"i", rootScopeValue} - if rootScopeRelay != "" { - iTag = append(iTag, rootScopeRelay) + if target.Kind.IsAddressable() || target.Kind.IsReplaceable() { + aValue := fmt.Sprintf("%d:%s:%s", target.Kind, target.PubKey.Hex(), dtag()) + aTag := nostr.Tag{"a", aValue} + if relayHint != "" { + aTag = append(aTag, relayHint) } - evt.Tags = append(evt.Tags, iTag) - } else { - if target.Kind.IsAddressable() || target.Kind.IsReplaceable() { - aValue := fmt.Sprintf("%d:%s:%s", target.Kind, target.PubKey.Hex(), dtag()) - aTag := nostr.Tag{"a", aValue} - if relayHint != "" { - aTag = append(aTag, relayHint) - } - evt.Tags = append(evt.Tags, aTag) - } - eTag := nostr.Tag{"e", target.ID.Hex()} - if target.PubKey != (nostr.PubKey{}) { - // same here: keep the pubkey in the 4th position - eTag = append(eTag, relayHint, target.PubKey.Hex()) - } else if relayHint != "" { - eTag = append(eTag, relayHint) - } - evt.Tags = append(evt.Tags, eTag) + evt.Tags = append(evt.Tags, aTag) } + eTag := nostr.Tag{"e", target.ID.Hex()} + if target.PubKey != (nostr.PubKey{}) { + // same here: keep the pubkey in the 4th position + eTag = append(eTag, relayHint, target.PubKey.Hex()) + } else if relayHint != "" { + eTag = append(eTag, relayHint) + } + evt.Tags = append(evt.Tags, eTag) evt.Tags = append(evt.Tags, nostr.Tag{"k", fmt.Sprint(target.Kind)})