Skip to content

Commit 4bde15e

Browse files
authored
feat: update relay contact configs to adhere to nip-11 (#63)
1 parent 357d59f commit 4bde15e

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

cmd/install.go

+11-8
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,21 @@ var installCmd = &cobra.Command{
6464
}
6565

6666
var relayContact string
67-
if selectedRelayOption == khatru_pyramid.RelayName || selectedRelayOption == nostr_rs_relay.RelayName || selectedRelayOption == khatru29.RelayName {
67+
if selectedRelayOption == wot_relay.RelayName {
6868
pterm.Println()
69-
pterm.Println(pterm.Yellow("Leave email empty if you don't want to provide relay contact information."))
69+
pterm.Println(pterm.Yellow("If you leave the relay contact information empty, then the relay's public key will be used."))
7070

7171
pterm.Println()
72-
relayContact, _ = pterm.DefaultInteractiveTextInput.Show("Email address")
73-
} else if selectedRelayOption == wot_relay.RelayName {
72+
relayContact, _ = pterm.DefaultInteractiveTextInput.Show("Email address/Public key (hex not npub)")
73+
} else {
7474
pterm.Println()
75-
pterm.Println(pterm.Yellow("If you leave the relay contact information empty, then the relay's public key will be used."))
75+
pterm.Println(pterm.Yellow("Leave email empty if you don't want to provide relay contact information."))
7676

7777
pterm.Println()
78-
relayContact, _ = pterm.DefaultInteractiveTextInput.Show("Email address/Public key (hex not npub)")
78+
relayContact, _ = pterm.DefaultInteractiveTextInput.Show("Email address")
79+
if relayContact != "" {
80+
relayContact = fmt.Sprintf("mailto:%s", relayContact)
81+
}
7982
}
8083

8184
pterm.Println()
@@ -151,7 +154,7 @@ var installCmd = &cobra.Command{
151154
strfry.InstallRelayBinary()
152155

153156
// Step 8: Set up the relay service
154-
strfry.SetupRelayService(relayDomain)
157+
strfry.SetupRelayService(relayDomain, relayContact)
155158

156159
// Step 9: Show success messages
157160
strfry.SuccessMessages(relayDomain, httpsEnabled)
@@ -208,7 +211,7 @@ var installCmd = &cobra.Command{
208211
strfry29.InstallRelayBinary()
209212

210213
// Step 8: Set up the relay service
211-
strfry29.SetupRelayService(relayDomain, privKey)
214+
strfry29.SetupRelayService(relayDomain, privKey, relayContact)
212215

213216
// Step 9: Show success messages
214217
strfry29.SuccessMessages(relayDomain, httpsEnabled)

pkg/relays/strfry/service.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
// Function to set up the relay service
13-
func SetupRelayService(domain string) {
13+
func SetupRelayService(domain, relayContact string) {
1414
spinner, _ := pterm.DefaultSpinner.Start("Configuring relay service...")
1515

1616
// Ensure the data directory exists and set ownership
@@ -42,6 +42,9 @@ func SetupRelayService(domain string) {
4242
// Determine preferred nofiles value
4343
files.InPlaceEdit(`s|nofiles = .*|nofiles = 0|`, TmpConfigFilePath)
4444

45+
// Construct the sed command to change the contact
46+
files.InPlaceEdit(fmt.Sprintf(`s|contact = ".*"|contact = "%s"|`, relayContact), TmpConfigFilePath)
47+
4548
// Copy config file to config directory
4649
files.CopyFile(TmpConfigFilePath, ConfigDirPath)
4750

pkg/relays/strfry29/service.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
// Function to set up the relay service
14-
func SetupRelayService(domain, relaySecretKey string) {
14+
func SetupRelayService(domain, relaySecretKey, relayContact string) {
1515
spinner, _ := pterm.DefaultSpinner.Start("Configuring relay service...")
1616

1717
// Ensure the data directory exists and set ownership
@@ -48,6 +48,9 @@ func SetupRelayService(domain, relaySecretKey string) {
4848
// Construct the sed command to change the info description
4949
files.InPlaceEdit(fmt.Sprintf(`s|description = ".*"|description = "%s"|`, ConfigFileInfoDescription), TmpConfigFilePath)
5050

51+
// Construct the sed command to change the contact
52+
files.InPlaceEdit(fmt.Sprintf(`s|contact = ".*"|contact = "%s"|`, relayContact), TmpConfigFilePath)
53+
5154
// Construct the sed command to change the plugin path
5255
files.InPlaceEdit(fmt.Sprintf(`s|plugin = ".*"|plugin = "%s"|`, BinaryPluginFilePath), TmpConfigFilePath)
5356

0 commit comments

Comments
 (0)