-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathclients.go
147 lines (133 loc) · 6.73 KB
/
clients.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package main
import (
"strings"
"github.com/a-h/templ"
)
type ClientReference struct {
ID string
Name string
Base string
URL templ.SafeURL
Platform string
}
const (
platformWeb = "web"
platformIOS = "ios"
platformAndroid = "android"
)
var (
native = ClientReference{ID: "native", Name: "Your default app", Base: "nostr:{code}", Platform: "native"}
nosta = ClientReference{ID: "nosta", Name: "Nosta", Base: "https://nosta.me/{code}", Platform: platformWeb}
snort = ClientReference{ID: "snort", Name: "Snort", Base: "https://snort.social/{code}", Platform: platformWeb}
olasWeb = ClientReference{ID: "olas", Name: "Olas", Base: "https://olas.app/e/{code}", Platform: platformWeb}
primalWeb = ClientReference{ID: "primal", Name: "Primal", Base: "https://primal.net/e/{code}", Platform: platformWeb}
nostrudel = ClientReference{ID: "nostrudel", Name: "Nostrudel", Base: "https://nostrudel.ninja/#/n/{code}", Platform: platformWeb}
nostter = ClientReference{ID: "nostter", Name: "Nostter", Base: "https://nostter.app/{code}", Platform: platformWeb}
nostterRelay = ClientReference{ID: "nostter", Name: "Nostter", Base: "https://nostter.app/relays/wss%3A%2F%2F{code}", Platform: platformWeb}
jumble = ClientReference{ID: "jumble", Name: "Jumble", Base: "https://jumble.social/notes/{code}", Platform: platformWeb}
jumbleRelay = ClientReference{ID: "jumble", Name: "Jumble", Base: "https://jumble.social/?r=wss://{code}", Platform: platformWeb}
coracle = ClientReference{ID: "coracle", Name: "Coracle", Base: "https://coracle.social/{code}", Platform: platformWeb}
coracleRelay = ClientReference{ID: "coracle", Name: "Coracle", Base: "https://coracle.social/relays/{code}", Platform: platformWeb}
zapStream = ClientReference{ID: "zap.stream", Name: "zap.stream", Base: "https://zap.stream/{code}", Platform: platformWeb}
nostrrrRelay = ClientReference{ID: "nostrrr", Name: "Nostrrr", Base: "https://nostrrr.com/relay/{code}", Platform: platformWeb}
nostrrrProfile = ClientReference{ID: "nostrrr", Name: "Nostrrr", Base: "https://nostrrr.com/p/{code}", Platform: platformWeb}
yakihonne = ClientReference{ID: "yakihonne", Name: "YakiHonne", Base: "https://yakihonne.com/{code}", Platform: platformWeb}
habla = ClientReference{ID: "habla", Name: "Habla", Base: "https://habla.news/a/{code}", Platform: platformWeb}
highlighter = ClientReference{ID: "highlighter", Name: "Highlighter", Base: "https://highlighter.com/a/{code}", Platform: platformWeb}
notestack = ClientReference{ID: "notestack", Name: "Notestack", Base: "https://notestack.com/{code}", Platform: platformWeb}
voyage = ClientReference{ID: "voyage", Name: "Voyage", Base: "intent:{code}#Intent;scheme=nostr;package=com.dluvian.voyage;end`;", Platform: platformAndroid}
olasAndroid = ClientReference{ID: "olas", Name: "Olas", Base: "intent:{code}#Intent;scheme=nostr;package=com.pablof7z.snapstr;end`;", Platform: platformAndroid}
primalAndroid = ClientReference{ID: "primal", Name: "Primal", Base: "intent:{code}#Intent;scheme=nostr;package=net.primal.android;end`;", Platform: platformAndroid}
yakihonneAndroid = ClientReference{ID: "yakihonne", Name: "Yakihonne", Base: "intent:{code}#Intent;scheme=nostr;package=com.yakihonne.yakihonne;end`;", Platform: platformAndroid}
freeFromAndroid = ClientReference{ID: "freefrom", Name: "FreeFrom", Base: "intent:{code}#Intent;scheme=nostr;package=com.freefrom;end`;", Platform: platformAndroid}
yanaAndroid = ClientReference{ID: "yana", Name: "Yana", Base: "intent:{code}#Intent;scheme=nostr;package=yana.nostr;end`;", Platform: platformAndroid}
amethyst = ClientReference{ID: "amethyst", Name: "Amethyst", Base: "intent:{code}#Intent;scheme=nostr;package=com.vitorpamplona.amethyst;end`;", Platform: platformAndroid}
nos = ClientReference{ID: "nos", Name: "Nos", Base: "nos:{code}", Platform: platformIOS}
damus = ClientReference{ID: "damus", Name: "Damus", Base: "damus:{code}", Platform: platformIOS}
nostur = ClientReference{ID: "nostur", Name: "Nostur", Base: "nostur:{code}", Platform: platformIOS}
olasIOS = ClientReference{ID: "olas", Name: "Olas", Base: "olas:{code}", Platform: platformIOS}
primalIOS = ClientReference{ID: "primal", Name: "Primal", Base: "primal:{code}", Platform: platformIOS}
freeFromIOS = ClientReference{ID: "freefrom", Name: "FreeFrom", Base: "freefrom:{code}", Platform: platformIOS}
yakihonneIOS = ClientReference{ID: "yakihonne", Name: "Yakihonne", Base: "yakihhone:{code}", Platform: platformIOS}
wikistr = ClientReference{ID: "wikistr", Name: "Wikistr", Base: "https://Wikistr.com/{handle}*{authorPubkey}", Platform: "web"}
wikifreedia = ClientReference{ID: "wikifreedia", Name: "Wikifreedia", Base: "https://wikifreedia.xyz/{handle}/{npub}", Platform: "web"}
)
func generateClientList(
kind int,
code string,
withModifiers ...func(ClientReference, string) string,
) []ClientReference {
var clients []ClientReference
switch kind {
case -1: // relays
clients = []ClientReference{
native,
jumbleRelay, nostterRelay, nostrrrRelay, coracleRelay,
}
case 1, 6:
clients = []ClientReference{
native,
damus, nostur, freeFromIOS, yakihonneIOS, nos, primalIOS,
voyage, yakihonneAndroid, primalAndroid, freeFromAndroid, yanaAndroid,
coracle, snort, jumble, nostter, nostrudel, primalWeb,
}
case 20:
clients = []ClientReference{
native,
olasAndroid,
olasIOS,
jumble, olasWeb,
}
case 0:
clients = []ClientReference{
native,
nos, damus, nostur, primalIOS, freeFromIOS, yakihonneIOS,
voyage, yakihonneAndroid, yanaAndroid, freeFromAndroid, primalAndroid,
nostrrrProfile, nosta, coracle, snort, nostter, nostrudel, primalWeb,
}
case 30023, 30024:
clients = []ClientReference{
native,
damus, nos, nostur, yakihonneIOS,
yakihonneAndroid, amethyst,
highlighter, yakihonne, habla, notestack,
}
case 1063:
clients = []ClientReference{
native,
amethyst,
snort, coracle, nostrudel,
}
case 30311:
clients = []ClientReference{
native,
amethyst,
nostur,
zapStream, coracle, nostrudel,
}
case 30818:
clients = []ClientReference{
native,
wikistr, wikifreedia,
}
case 31922, 31923:
clients = []ClientReference{
native,
coracle,
}
default:
clients = []ClientReference{
native,
yakihonneIOS, nos, damus, nostur, primalIOS, freeFromIOS,
voyage, amethyst, yakihonneAndroid, yanaAndroid, freeFromAndroid, voyage,
yakihonne, coracle, snort, nostter, nostrudel, primalWeb,
}
}
for i, c := range clients {
clients[i].URL = templ.SafeURL(strings.Replace(c.Base, "{code}", code, -1))
for _, modifier := range withModifiers {
clients[i].URL = templ.SafeURL(modifier(c, string(clients[i].URL)))
}
}
return clients
}