made Profilepicture (experimental) optional

This commit is contained in:
Believethehype
2023-03-15 18:57:49 +01:00
parent f42ff7a12b
commit 24ec61a197
3 changed files with 11 additions and 12 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ Federated Lightning Address Server (with NIP57 Zap support)
> The Nostr private key in the parameters should be in bench32 format (`nsec..`) and it should be a new one. It is needed to sign messages only, so does not need to be your main account key.
(`GetNostrProfile`) is still experimental and should be left on false in case it causes errors. The idea is to provide the Nostr Profile picture to wallets that support it.
(`GET_NOSTR_PROFILE`) is still experimental and should be left on false in case it causes errors. The idea is to provide the Nostr Profile picture to wallets that support it.
```
PORT=17422
@@ -23,7 +23,7 @@ SITE_NAME=Bitmia
NOSTR_PRIVATE_KEY=nsec213....
FORWARD_URL=https://thepageyouwanttoshowasmainpage.com
NIP05=true
GetNostrProfile=false
GET_NOSTR_PROFILE=false
```
3. Start the app with `./satdress` or `nohup ./satdress &` for a background task
+5 -5
View File
@@ -24,16 +24,16 @@ type Settings struct {
Domain string `envconfig:"DOMAIN" required:"true"`
// GlobalUsers means that user@ part is globally unique across all domains
// WARNING: if you toggle this existing users won't work anymore for safety reasons!
GlobalUsers bool `envconfig:"GLOBAL_USERS" required:"false" default:false`
GlobalUsers bool `envconfig:"GLOBAL_USERS" default:"false"`
Secret string `envconfig:"SECRET" required:"true"`
SiteOwnerName string `envconfig:"SITE_OWNER_NAME" required:"true"`
SiteOwnerURL string `envconfig:"SITE_OWNER_URL" required:"true"`
SiteName string `envconfig:"SITE_NAME" required:"true"`
NostrPrivateKey string `envconfig:"NOSTR_PRIVATE_KEY" required:"false" default:""`
ForwardMainPageUrl string `envconfig:"FORWARD_URL"`
Nip05 bool `envconfig:"NIP05" required:"false" default:false`
GetNostrProfile bool `envconfig:"GetNostrProfile" required:"false" default:false`
ForceMigrate bool `envconfig:"FORCE_MIGRATE" required:"false" default:false`
ForwardMainPageUrl string `envconfig:"FORWARD_URL" required:"false"`
Nip05 bool `envconfig:"NIP05" default:"false" required:"false"`
GetNostrProfile bool `envconfig:"GET_NOSTR_PROFILE" required:"false" default:"false"`
ForceMigrate bool `envconfig:"FORCE_MIGRATE" default:"false"`
TorProxyURL string `envconfig:"TOR_PROXY_URL"`
}
+4 -5
View File
@@ -82,14 +82,13 @@ func handleNip05(w http.ResponseWriter, r *http.Request) {
}
func GetNostrProfileMetaData(npub string) (nostr.ProfileMetadata, error) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
ctx, _ := context.WithTimeout(context.Background(), 3*time.Second)
var metadata *nostr.ProfileMetadata
// connect to any relay
url := "wss://relay.damus.io"
relay, err := nostr.RelayConnect(ctx, url)
if err != nil {
cancel()
return *metadata, err
}
@@ -105,7 +104,6 @@ func GetNostrProfileMetaData(npub string) (nostr.ProfileMetadata, error) {
Limit: 1,
}}
} else {
cancel()
return *metadata, err
}
@@ -114,15 +112,16 @@ func GetNostrProfileMetaData(npub string) (nostr.ProfileMetadata, error) {
go func() {
<-sub.EndOfStoredEvents
cancel()
}()
for ev := range sub.Events {
evs = append(evs, *ev)
}
metadata, err = nostr.ParseMetadata(evs[0])
relay.Close()
metadata, err = nostr.ParseMetadata(evs[0])
return *metadata, err
}