mirror of
https://github.com/fiatjaf/nak.git
synced 2026-07-22 07:48:27 +00:00
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.
This commit is contained in:
36
publish.go
36
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)})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user