client url modifiers to fix streams on nostrudel.

This commit is contained in:
fiatjaf
2024-01-08 10:10:24 -03:00
parent 3c4c5be320
commit aad148f018
2 changed files with 12 additions and 2 deletions

View File

@@ -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

View File

@@ -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,
})