Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Commit

Permalink
feat: #22 implement custom NIP-11 support parametrizable
Browse files Browse the repository at this point in the history
  • Loading branch information
piraces committed Feb 12, 2023
1 parent 395cfda commit c4fe528
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
6 changes: 4 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SECRET=test
DB_DIR="/db/rsslay.sqlite"
DEFAULT_PROFILE_PICTURE_URL="https://i.imgur.com/MaceU96.png"
SECRET="CHANGE_ME"
VERSION=0.3.6
VERSION=0.4.1
REPLAY_TO_RELAYS=false
RELAYS_TO_PUBLISH_TO=""
DEFAULT_WAIT_TIME_BETWEEN_BATCHES=60000
Expand All @@ -15,4 +15,6 @@ MAX_EVENTS_TO_REPLAY=10
ENABLE_AUTO_NIP05_REGISTRATION=false
MAIN_DOMAIN_NAME=""
OWNER_PUBLIC_KEY=""
MAX_SUBROUTINES=20
MAX_SUBROUTINES=20
INFO_RELAY_NAME="rsslay"
INFO_CONTACT=""
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ENV PORT="8080"
ENV DB_DIR="/db/rsslay.sqlite"
ENV DEFAULT_PROFILE_PICTURE_URL="https://i.imgur.com/MaceU96.png"
ENV SECRET="CHANGE_ME"
ENV VERSION=0.3.6
ENV VERSION=0.4.1
ENV REPLAY_TO_RELAYS=false
ENV RELAYS_TO_PUBLISH_TO=""
ENV DEFAULT_WAIT_TIME_BETWEEN_BATCHES=60000
Expand All @@ -38,6 +38,8 @@ ENV ENABLE_AUTO_NIP05_REGISTRATION=false
ENV MAIN_DOMAIN_NAME=""
ENV OWNER_PUBLIC_KEY=""
ENV MAX_SUBROUTINES=20
ENV INFO_RELAY_NAME="rsslay"
ENV INFO_CONTACT=""

COPY --from=build /rsslay .
COPY --from=build /app/web/assets/ ./web/assets/
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.fly
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ENV PORT="8080"
ENV DB_DIR="/db/rsslay.sqlite"
ENV DEFAULT_PROFILE_PICTURE_URL="https://i.imgur.com/MaceU96.png"
ENV SECRET="CHANGE_ME"
ENV VERSION=0.3.6
ENV VERSION=0.4.1
ENV REPLAY_TO_RELAYS=false
ENV RELAYS_TO_PUBLISH_TO=""
ENV DEFAULT_WAIT_TIME_BETWEEN_BATCHES=60000
Expand All @@ -40,6 +40,8 @@ ENV ENABLE_AUTO_NIP05_REGISTRATION=false
ENV MAIN_DOMAIN_NAME=""
ENV OWNER_PUBLIC_KEY=""
ENV MAX_SUBROUTINES=20
ENV INFO_RELAY_NAME="rsslay"
ENV INFO_CONTACT=""

COPY --from=litefs /usr/local/bin/litefs /usr/local/bin/litefs
COPY --from=build /rsslay /usr/local/bin/rsslay
Expand Down
8 changes: 7 additions & 1 deletion Dockerfile.railwayapp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ARG ENABLE_AUTO_NIP05_REGISTRATION
ARG MAIN_DOMAIN_NAME
ARG OWNER_PUBLIC_KEY
ARG MAX_SUBROUTINES
ARG INFO_RELAY_NAME
ARG INFO_CONTACT

WORKDIR /app

Expand Down Expand Up @@ -45,6 +47,8 @@ ARG ENABLE_AUTO_NIP05_REGISTRATION
ARG MAIN_DOMAIN_NAME
ARG OWNER_PUBLIC_KEY
ARG MAX_SUBROUTINES
ARG INFO_RELAY_NAME
ARG INFO_CONTACT

LABEL org.opencontainers.image.title="rsslay"
LABEL org.opencontainers.image.source=https://github.com/piraces/rsslay
Expand All @@ -56,7 +60,7 @@ ENV PORT=$PORT
ENV DB_DIR=$DB_DIR
ENV DEFAULT_PROFILE_PICTURE_URL=$DEFAULT_PROFILE_PICTURE_URL
ENV SECRET=$SECRET
ENV VERSION=0.3.6
ENV VERSION=0.4.1
ENV REPLAY_TO_RELAYS=false
ENV RELAYS_TO_PUBLISH_TO=""
ENV DEFAULT_WAIT_TIME_BETWEEN_BATCHES=60000
Expand All @@ -66,6 +70,8 @@ ENV ENABLE_AUTO_NIP05_REGISTRATION="false"
ENV MAIN_DOMAIN_NAME=""
ENV OWNER_PUBLIC_KEY=""
ENV MAX_SUBROUTINES=20
ENV INFO_RELAY_NAME="rsslay"
ENV INFO_CONTACT=""

COPY --from=build /rsslay .
COPY --from=build /app/web/assets/ ./web/assets/
Expand Down
23 changes: 22 additions & 1 deletion cmd/rsslay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/kelseyhightower/envconfig"
_ "github.com/mattn/go-sqlite3"
"github.com/nbd-wtf/go-nostr"
"github.com/nbd-wtf/go-nostr/nip11"
"github.com/piraces/rsslay/internal/handlers"
"github.com/piraces/rsslay/pkg/events"
"github.com/piraces/rsslay/pkg/feed"
Expand Down Expand Up @@ -48,6 +49,8 @@ type Relay struct {
MainDomainName string `envconfig:"MAIN_DOMAIN_NAME" default:""`
OwnerPublicKey string `envconfig:"OWNER_PUBLIC_KEY" default:""`
MaxSubroutines int `envconfig:"MAX_SUBROUTINES" default:"20"`
RelayName string `envconfig:"INFO_RELAY_NAME" default:"rsslay"`
Contact string `envconfig:"INFO_CONTACT" default:"~"`

updates chan nostr.Event
lastEmitted sync.Map
Expand Down Expand Up @@ -78,7 +81,7 @@ func CreateHealthCheck() {
}

func (r *Relay) Name() string {
return "rsslay"
return r.RelayName
}

func (r *Relay) OnInitialized(s *relayer.Server) {
Expand Down Expand Up @@ -263,6 +266,24 @@ func (r *Relay) InjectEvents() chan nostr.Event {
return r.updates
}

func (r *Relay) GetNIP11InformationDocument() nip11.RelayInformationDocument {
infoDocument := nip11.RelayInformationDocument{
Name: relayInstance.Name(),
Description: "Relay that creates virtual nostr profiles for each RSS feed submitted, powered by the relayer framework",
PubKey: relayInstance.OwnerPublicKey,
Contact: relayInstance.Contact,
SupportedNIPs: []int{5, 9, 11, 12, 15, 16, 19, 20},
Software: "git+https://github.com/piraces/rsslay.git",
Version: relayInstance.Version,
}

if relayInstance.OwnerPublicKey == "" {
infoDocument.PubKey = "~"
}

return infoDocument
}

func main() {
CreateHealthCheck()
defer func(db *sql.DB) {
Expand Down
3 changes: 3 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ app = "rsslay"
ENABLE_AUTO_NIP05_REGISTRATION = "true"
OWNER_PUBLIC_KEY = "072d52c5955d40a26b74f9957bee187c2a750d68e01247b16ad9b96ed6b00927"
MAX_SUBROUTINES = 20
INFO_RELAY_NAME = "rsslay public instance"
INFO_CONTACT = "mailto:[email protected]"
VERSION = "0.4.1"

[[services]]
internal_port = 8080
Expand Down

0 comments on commit c4fe528

Please sign in to comment.