mirror of
https://github.com/aljazceru/njump.git
synced 2026-02-23 15:04:22 +01:00
client url modifiers to fix streams on nostrudel.
This commit is contained in:
@@ -49,7 +49,7 @@ var (
|
||||
plebstrIOS = ClientReference{ID: "plebstr", Name: "Plebstr", Base: "plebstr:{code}", Platform: "ios"}
|
||||
)
|
||||
|
||||
func generateClientList(kind int, code string) []ClientReference {
|
||||
func generateClientList(kind int, code string, withModifiers ...func(string) string) []ClientReference {
|
||||
var clients []ClientReference
|
||||
switch kind {
|
||||
case -1: // relays
|
||||
@@ -101,6 +101,9 @@ func generateClientList(kind int, code string) []ClientReference {
|
||||
|
||||
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(string(clients[i].URL)))
|
||||
}
|
||||
}
|
||||
|
||||
return clients
|
||||
|
||||
@@ -401,7 +401,14 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
|
||||
Subject: subject,
|
||||
TitleizedContent: titleizedContent,
|
||||
Alt: data.alt,
|
||||
Clients: generateClientList(data.event.Kind, data.naddr),
|
||||
Clients: generateClientList(data.event.Kind, data.naddr,
|
||||
func(s string) string {
|
||||
if strings.Contains(s, "nostrudel") {
|
||||
s = strings.Replace(s, "/u/", "/streams/", 1)
|
||||
}
|
||||
return s
|
||||
},
|
||||
),
|
||||
|
||||
LiveEvent: *data.kind30311Metadata,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user