summaryrefslogtreecommitdiffstats
path: root/internal/nostr/kinds.go
diff options
context:
space:
mode:
authorbndw <ben@bdw.to>2026-02-13 17:35:32 -0800
committerbndw <ben@bdw.to>2026-02-13 17:35:32 -0800
commit581ceecbf046f99b39885c74e2780a5320e5b15e (patch)
treec82dcaddb4f555d5051684221881e36f7fe3f718 /internal/nostr/kinds.go
parent06b9b13274825f797523935494a1b5225f0e0862 (diff)
feat: add Nostr protocol implementation (internal/nostr, internal/websocket)
Diffstat (limited to 'internal/nostr/kinds.go')
-rw-r--r--internal/nostr/kinds.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/internal/nostr/kinds.go b/internal/nostr/kinds.go
new file mode 100644
index 0000000..cb76e88
--- /dev/null
+++ b/internal/nostr/kinds.go
@@ -0,0 +1,51 @@
1package nostr
2
3// Event kind constants as defined in NIP-01 and related NIPs.
4const (
5 KindMetadata = 0
6 KindTextNote = 1
7 KindContactList = 3
8 KindEncryptedDM = 4
9 KindDeletion = 5
10 KindRepost = 6
11 KindReaction = 7
12)
13
14// IsRegular returns true if the kind is a regular event (stored, not replaced).
15// Regular events: 1000 <= kind < 10000 or kind in {0,1,2,...} except replaceable ones.
16func IsRegular(kind int) bool {
17 if kind == KindMetadata || kind == KindContactList {
18 return false
19 }
20 if kind >= 10000 && kind < 20000 {
21 return false // replaceable
22 }
23 if kind >= 20000 && kind < 30000 {
24 return false // ephemeral
25 }
26 if kind >= 30000 && kind < 40000 {
27 return false // addressable
28 }
29 return true
30}
31
32// IsReplaceable returns true if the kind is replaceable (NIP-01).
33// Replaceable events: 10000 <= kind < 20000, or kind 0 (metadata) or kind 3 (contact list).
34func IsReplaceable(kind int) bool {
35 if kind == KindMetadata || kind == KindContactList {
36 return true
37 }
38 return kind >= 10000 && kind < 20000
39}
40
41// IsEphemeral returns true if the kind is ephemeral (not stored).
42// Ephemeral events: 20000 <= kind < 30000.
43func IsEphemeral(kind int) bool {
44 return kind >= 20000 && kind < 30000
45}
46
47// IsAddressable returns true if the kind is addressable (parameterized replaceable).
48// Addressable events: 30000 <= kind < 40000.
49func IsAddressable(kind int) bool {
50 return kind >= 30000 && kind < 40000
51}