Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN npm install tailwindcss
RUN npx tailwind -i base.css -o tailwind-bundle.min.css --minify

#### Go build stage
FROM golang:1.24.2-alpine AS gobuilder
FROM golang:1-alpine AS gobuilder

# Add package
RUN apk add --no-cache autoconf automake libtool build-base musl-dev git
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ DISK_CACHE_PATH="/tmp/njump-internal"
EVENT_STORE_PATH="/tmp/njump-db"
TAILWIND_DEBUG=
RELAY_CONFIG_PATH=
CLIENTS_CONFIG_PATH=
TRUSTED_PUBKEYS=npub1...,npub1...
```

---

`RELAY_CONFIG_PATH` is path to json file to update relay configuration. You can set relay list like below:

```json
Expand All @@ -75,3 +78,7 @@ TRUSTED_PUBKEYS=npub1...,npub1...
See `relay-config.json.sample` for example.

For example, when running from a precompiled binary you can do something like `PORT=5000 ./njump`.

---

`CLIENTS_CONFIG_PATH` is path to json file to update the clients list. You can find the default at [/clients.json](./clients.json)
172 changes: 34 additions & 138 deletions clients.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"strconv"
"strings"

"github.com/a-h/templ"
Expand All @@ -14,158 +15,53 @@ type ClientReference struct {
Platform string
}

const (
platformWeb = "web"
platformIOS = "ios"
platformAndroid = "android"
)

var (
native = ClientReference{ID: "native", Name: "Your default app", Base: "nostr:{code}", Platform: "native"}
defaultWeb = ClientReference{ID: "default-web", Name: "Your default web app", Base: "web+nostr:{code}", Platform: "web"}

nosotros = ClientReference{ID: "nosotros", Name: "Nosotros", Base: "https://dev.nosotros.app/{code}", Platform: platformWeb}
nosotrosRelay = ClientReference{ID: "nosotros", Name: "Nosotros", Base: "https://dev.nosotros.app/feed?kind=%5B1%2C6%5D&limit=100&type=relayfeed&relay=wss%3A%2F%2F{code}", Platform: platformWeb}
nosta = ClientReference{ID: "nosta", Name: "Nosta", Base: "https://nosta.me/{code}", Platform: platformWeb}
phoenix = ClientReference{ID: "phoenix", Name: "Phoenix", Base: "https://phoenix.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/l/{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/{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/wss%3A%2F%2F{code}", Platform: platformWeb}
relayTools = ClientReference{ID: "relay.tools", Name: "relay.tools", Base: "https://relay.tools/posts/?relay=wss://{code}"}
iris = ClientReference{ID: "iris", Name: "Iris", Base: "https://iris.to/{code}", Platform: "web"}
lumilumi = ClientReference{ID: "lumilumi", Name: "Lumilumi", Base: "https://lumilumi.app/{code}", Platform: platformWeb}
lumilumiRelay = ClientReference{ID: "lumilumi", Name: "Lumilumi", Base: "https://lumilumi.app/relay/wss%3A%2F%2F{code}", Platform: platformWeb}
chachiRelay = ClientReference{ID: "chachi", Name: "chachi", Base: "https://chachi.chat/relay/wss%3A%2F%2F{code}/feed"}
yakihonne = ClientReference{ID: "yakihonne", Name: "YakiHonne", Base: "https://yakihonne.com/{code}", Platform: platformWeb}
yakihonneRelay = ClientReference{ID: "yakihonne", Name: "YakiHonne", Base: "https://yakihonne.com/r/?r=wss://{code}", Platform: platformWeb}

zapStream = ClientReference{ID: "zap.stream", Name: "zap.stream", Base: "https://zap.stream/{code}", Platform: platformWeb}
shosho = ClientReference{ID: "shosho", Name: "Shosho", Base: "https://shosho.live/live/{code}", Platform: platformWeb}

habla = ClientReference{ID: "habla", Name: "Habla", Base: "https://habla.news/a/{code}", Platform: platformWeb}
pareto = ClientReference{ID: "pareto", Name: "Pareto", Base: "https://pareto.space/a/{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}
type ClientsConfig struct {
Clients map[string]clientData `json:"clients"`
KindMappings map[string][]string `json:"kindMappings"`
}

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}
type clientData struct {
Name string `json:"name"`
Base string `json:"base"`
Platform string `json:"platform"`
}

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"}
var (
clientConfig ClientsConfig
)

func generateClientList(
kind int,
code string,
withModifiers ...func(ClientReference, string) string,
) []ClientReference {
var clients []ClientReference
switch kind {
case -1: // relays
clients = []ClientReference{
native,
nostur, yakihonneAndroid, yakihonneIOS,
jumbleRelay, yakihonneRelay, chachiRelay, nosotrosRelay, lumilumiRelay, coracleRelay, relayTools, nostterRelay,
defaultWeb,
}
case 1, 6:
clients = []ClientReference{
native,
damus, nostur, freeFromIOS, yakihonneIOS, nos, primalIOS,
voyage, yakihonneAndroid, primalAndroid, freeFromAndroid, yanaAndroid,
nosotros, jumble, coracle, lumilumi, nostter, nostrudel, phoenix, primalWeb, iris,
}
case 20:
clients = []ClientReference{
native,
olasAndroid,
olasIOS,
nosotros, lumilumi, jumble, olasWeb, coracle,
defaultWeb,
}
case 0:
clients = []ClientReference{
native,
nos, damus, nostur, primalIOS, freeFromIOS, yakihonneIOS,
voyage, yakihonneAndroid, yanaAndroid, freeFromAndroid, primalAndroid,
nosotros, jumble, nosta, coracle, phoenix, nostter, nostrudel, primalWeb, iris,
defaultWeb,
}
case 30023, 30024:
clients = []ClientReference{
native,
damus, nos, nostur, yakihonneIOS,
yakihonneAndroid, amethyst,
yakihonne, lumilumi, coracle, pareto, habla,
defaultWeb,
}
case 1063:
clients = []ClientReference{
native,
amethyst,
lumilumi, phoenix, coracle, nostrudel,
defaultWeb,
}
case 9802:
clients = []ClientReference{
coracle,
nostrudel,
lumilumi,
jumble,
defaultWeb,
}
case 30311:
clients = []ClientReference{
native,
amethyst,
nostur,
zapStream, shosho, lumilumi, nostrudel,
defaultWeb,
}
case 30818:
clients = []ClientReference{
native,
wikistr, wikifreedia,
defaultWeb,
}
case 31922, 31923:
clients = []ClientReference{
native,
coracle,
defaultWeb,
kindKey := strconv.Itoa(kind)
clientIDs, ok := clientConfig.KindMappings[kindKey]
if !ok {
clientIDs = clientConfig.KindMappings["default"]
}

clients := make([]ClientReference, 0, len(clientIDs))
for _, id := range clientIDs {
clientInfo, ok := clientConfig.Clients[id]
if !ok {
continue
}
default:
clients = []ClientReference{
native,
yakihonneIOS, nos, damus, nostur, primalIOS, freeFromIOS,
voyage, amethyst, yakihonneAndroid, yanaAndroid, freeFromAndroid, voyage,
yakihonne, coracle, phoenix, nostter, nostrudel, primalWeb, iris,
defaultWeb,

c := ClientReference{
ID: id,
Name: clientInfo.Name,
Base: clientInfo.Base,
Platform: clientInfo.Platform,
}
}

for i, c := range clients {
clients[i].URL = templ.SafeURL(strings.Replace(c.Base, "{code}", code, -1))
url := strings.Replace(c.Base, "{code}", code, -1)
for _, modifier := range withModifiers {
clients[i].URL = templ.SafeURL(modifier(c, string(clients[i].URL)))
url = modifier(c, url)
}
c.URL = templ.SafeURL(url)

clients = append(clients, c)
}

return clients
Expand Down
Loading