mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-26 05:31:28 +02:00
nip45: support kind:1111 comment counts.
This commit is contained in:
@@ -37,6 +37,20 @@ func HyperLogLogEventPubkeyOffsetsAndReferencesForEvent(evt *nostr.Event) iter.S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case 1111:
|
||||||
|
//
|
||||||
|
// comment counts:
|
||||||
|
e := evt.Tags.Find("E")
|
||||||
|
if e != nil {
|
||||||
|
v := e[1]
|
||||||
|
if nostr.IsValid32ByteHex(v) {
|
||||||
|
// 32th nibble of "e" tag
|
||||||
|
p, _ := strconv.ParseInt(v[32:33], 16, 64)
|
||||||
|
if !yield(v, int(p+8)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,18 +19,20 @@ func HyperLogLogEventPubkeyOffsetForFilter(filter nostr.Filter) int {
|
|||||||
|
|
||||||
// only serve the cases explicitly defined by the NIP:
|
// only serve the cases explicitly defined by the NIP:
|
||||||
if pTags, ok := filter.Tags["p"]; ok {
|
if pTags, ok := filter.Tags["p"]; ok {
|
||||||
//
|
if len(pTags) == 1 && nostr.IsValid32ByteHex(pTags[0]) {
|
||||||
// follower counts:
|
//
|
||||||
if filter.Kinds[0] == 3 && len(pTags) == 1 {
|
// follower counts:
|
||||||
// 32th nibble of "p" tag
|
if filter.Kinds[0] == 3 {
|
||||||
p, err := strconv.ParseInt(pTags[0][32:33], 16, 64)
|
// 32th nibble of "p" tag
|
||||||
if err != nil {
|
p, err := strconv.ParseInt(pTags[0][32:33], 16, 64)
|
||||||
return -1
|
if err != nil {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return int(p + 8)
|
||||||
}
|
}
|
||||||
return int(p + 8)
|
|
||||||
}
|
}
|
||||||
} else if eTags, ok := filter.Tags["e"]; ok {
|
} else if eTags, ok := filter.Tags["e"]; ok {
|
||||||
if len(eTags) == 1 {
|
if len(eTags) == 1 && nostr.IsValid32ByteHex(eTags[0]) {
|
||||||
//
|
//
|
||||||
// reaction counts:
|
// reaction counts:
|
||||||
if filter.Kinds[0] == 7 {
|
if filter.Kinds[0] == 7 {
|
||||||
@@ -42,6 +44,19 @@ func HyperLogLogEventPubkeyOffsetForFilter(filter nostr.Filter) int {
|
|||||||
return int(p + 8)
|
return int(p + 8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if eTags, ok := filter.Tags["E"]; ok {
|
||||||
|
if len(eTags) == 1 && nostr.IsValid32ByteHex(eTags[0]) {
|
||||||
|
//
|
||||||
|
// reaction counts:
|
||||||
|
if filter.Kinds[0] == 1111 {
|
||||||
|
// 32th nibble of "E" tag
|
||||||
|
p, err := strconv.ParseInt(eTags[0][32:33], 16, 64)
|
||||||
|
if err != nil {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return int(p + 8)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// everything else is false at least for now
|
// everything else is false at least for now
|
||||||
|
Reference in New Issue
Block a user