tinyrelayfile
tinyrelay/internal/event/kinds.go/

internal/event/kinds.go raw
1package event
2
3const (
4 KIND_PROFILE = 0
5 KIND_DELETION = 5
6 KIND_VANISH = 62
7 KIND_AUTH = 22242
8 KIND_DM = 14
9 KIND_WRAP = 1059
10 KIND_REPORT = 1984
11 KIND_NOSTR_CONNECT = 24133
12 KIND_APP_DATA = 30078
13 KIND_VIEW = KIND_APP_DATA
14 KIND_PRESENCE = 20078
15 KIND_MEMBER_ADDED = 8000
16 KIND_MEMBER_REMOVED = 8001
17 KIND_ROSTER = 13534
18 KIND_ROLE_DEF = 33534
19 KIND_NIP43_JOIN = 28934
20 KIND_NIP43_INVITE = 28935
21 KIND_NIP43_LEAVE = 28936
22 KIND_PUT_USER = 9000
23 KIND_REMOVE_USER = 9001
24 KIND_EDIT_METADATA = 9002
25 KIND_DELETE_EVENT = 9005
26 KIND_CREATE_GROUP = 9007
27 KIND_DELETE_GROUP = 9008
28 KIND_CREATE_INVITE = 9009
29 KIND_PINS = 9010
30 KIND_JOIN = 9021
31 KIND_LEAVE = 9022
32 KIND_GROUP_METADATA = 39000
33 KIND_GROUP_ADMINS = 39001
34 KIND_GROUP_MEMBERS = 39002
35 KIND_GROUP_ROLES = 39003
36 KIND_GROUP_PINS = 39005
37 KIND_RELAY_DISCOVERY = 30166
38 KIND_SITE = 15128
39 KIND_NAMED_SITE = 35128
40 KIND_SITE_SNAPSHOT = 5128
41 KIND_MARMOT_GROUP = 445
42 KIND_MARMOT_KEY_PACKAGE = 30443
43 KIND_REPO = 30617
44 KIND_REPO_STATE = 30618
45 KIND_GIT_PATCH = 1617
46 KIND_GIT_PR = 1618
47 KIND_GIT_PR_UPDATE = 1619
48 KIND_GIT_ISSUE = 1621
49 KIND_PUSH_REGISTRATION = 30390
50 KIND_CHAT = 9
51 KIND_THREAD = 11
52 KIND_THREAD_REPLY = 12
53 KIND_ROOM_PRESENCE = 20001
54 KIND_ROOM_TYPING = 20002
55 KIND_RICH_CONTENT = 40002
56 KIND_CONTENT_EDIT = 40003
57 KIND_ROOM_MEMBER_ADDED = 44100
58 KIND_ROOM_MEMBER_REMOVED = 44101
59
60 // NIP-54 wiki: articles, merge requests and redirects.
61 KIND_WIKI_ARTICLE = 30818
62 KIND_WIKI_MERGE = 818
63 KIND_WIKI_REDIRECT = 30819
64 KIND_AGENT_GRANT = 30392
65)
66
67// NIP-90 long tasks use request kinds 5000 to 5127 and 5129 to 5999.
68// Each request is answered by a result kind 1000 higher and by feedback
69// of kind 7000. Kind 5128 belongs to NIP-5A site snapshots.
70const (
71 KIND_JOB_REQUEST_MIN = 5000
72 KIND_JOB_REQUEST_MAX = 5999
73 KIND_JOB_RESULT_MIN = 6000
74 KIND_JOB_RESULT_MAX = 6999
75 KIND_JOB_FEEDBACK = 7000
76)
77
78// JobFeedbackStatuses is the NIP-90 vocabulary of the feedback status tag.
79var JobFeedbackStatuses = []string{"payment-required", "processing", "error", "success", "partial"}
80
81// JobInputTypes is the NIP-90 vocabulary of the i tag's input type.
82var JobInputTypes = []string{"url", "event", "job", "text"}
83
84// IsJobRequest reports whether kind belongs to long-task requests.
85// NIP-5A site snapshots have their own admission and manifest rules.
86func IsJobRequest(kind int) bool {
87 return kind >= KIND_JOB_REQUEST_MIN && kind <= KIND_JOB_REQUEST_MAX && kind != KIND_SITE_SNAPSHOT
88}
89
90// IsJobResult reports whether kind is a NIP-90 result kind.
91func IsJobResult(kind int) bool { return kind >= KIND_JOB_RESULT_MIN && kind <= KIND_JOB_RESULT_MAX }
92
93// IsJobKind reports whether the kind is a job request, result or feedback.
94func IsJobKind(kind int) bool {
95 return IsJobRequest(kind) || IsJobResult(kind) || kind == KIND_JOB_FEEDBACK
96}
97
98// JobResultKind returns the result kind for a request kind, or 0 for other
99// kinds.
100func JobResultKind(request int) int {
101 if !IsJobRequest(request) {
102 return 0
103 }
104 return request + 1000
105}
106
107// IsJobFeedbackStatus reports whether status is in the NIP-90 feedback
108// vocabulary.
109func IsJobFeedbackStatus(status string) bool {
110 for _, known := range JobFeedbackStatuses {
111 if known == status {
112 return true
113 }
114 }
115 return false
116}
117
118// IsJobInputType reports whether kind is a supported NIP-90 input type.
119func IsJobInputType(kind string) bool {
120 for _, known := range JobInputTypes {
121 if known == kind {
122 return true
123 }
124 }
125 return false
126}

About

ownerc01503e8035f
visibilitypublic
headd730679639bf

Maintainers

  • c01503e8035f owner
  • ba1b5beed5b5 agent hermes

Clone

  • https://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git

Refs