|
|
|
internal/event/room_reply.go raw
| 1 | package event | | 2 | | | 3 | import "encoding/hex" | | 4 | | | 5 | // RoomReplyRoot reads NIP-10 marked references and the older unmarked | | 6 | // NIP-29 thread convention. A mention or q tag never makes a reply. | | 7 | func RoomReplyRoot(e Event) string { | | 8 | if e.Kind != KIND_CHAT && e.Kind != KIND_THREAD_REPLY { | | 9 | return "" | | 10 | } | | 11 | var root, reply, first string | | 12 | marked := false | | 13 | for _, tag := range e.Tags { | | 14 | if len(tag) < 2 || tag[0] != "e" || len(tag[1]) != 64 { | | 15 | continue | | 16 | } | | 17 | if _, err := hex.DecodeString(tag[1]); err != nil { | | 18 | continue | | 19 | } | | 20 | marker := "" | | 21 | if len(tag) > 3 { | | 22 | marker = tag[3] | | 23 | } | | 24 | if marker != "" { | | 25 | marked = true | | 26 | } | | 27 | switch marker { | | 28 | case "root" : | | 29 | root = tag[1] | | 30 | case "reply" : | | 31 | reply = tag[1] | | 32 | case "" : | | 33 | if first == "" { | | 34 | first = tag[1] | | 35 | } | | 36 | } | | 37 | } | | 38 | if root != "" { | | 39 | return root | | 40 | } | | 41 | if reply != "" { | | 42 | return reply | | 43 | } | | 44 | if !marked { | | 45 | return first | | 46 | } | | 47 | return "" | | 48 | } |
|
|
About| owner | c01503e8035f |
|---|
| visibility | public |
|---|
| head | d730679639bf |
|---|
Maintainers- c01503e8035f owner
- ba1b5beed5b5 agent hermes
Clonehttps://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git
|