Add optional icon for NIP-11

This commit is contained in:
Mike Dilger 2024-11-05 10:10:40 +13:00
parent 006ecadf9c
commit 181750cb90
6 changed files with 25 additions and 1 deletions

View File

@ -90,6 +90,14 @@ key_pem_path = "/opt/chorus/etc/tls/privkey.pem"
# description = "A default config of the Chorus relay"
# This is an icon URL pointing to an image representing your relay, displayed in the NIP-11
# response.
#
# Default is not set
#
# icon_url =
# This is an optional contact for your relay, displayed in the NIP-11 response.
#
# Default is not set

View File

@ -87,6 +87,10 @@ This is an optional description for your relay, displayed in the NIP-11 response
Default is "A default config of the Chorus relay".
### icon_url
This is an optional URL for an graphical icon representing your relay, displayed in the NIP-11 response.
### contact
This is an optional contact for your relay, displayed in the NIP-11 response.

View File

@ -83,7 +83,7 @@ Go ahead and edit that file to your liking. In particular:
- Change the `ip_address` to your internet-accessible IP address (if you are running directly)
or to 127.0.0.1 with a local port like 8080 (if you are proxying behind nginx)
- Change the port if necessary
- Change the name, description, and contact (e.g. your email address) as desired
- Change the name, description, icon_url and contact (e.g. your email address) as desired
- Set your public_key_hex (it is an option, so use `Some()`)
- Set hex keys of users for which this relay will act as a personal relay

View File

@ -10,6 +10,7 @@ certchain_pem_path = "tls/fullchain.pem"
key_pem_path = "tls/privkey.pem"
name = "Chorus Sample"
description = "A sample run of the Chorus relay"
# icon_url =
open_relay = false
user_hex_keys = [
"ee11a5dff40c19a555f41fe42b48f00e618c91225622ae37b6c2bb67b76c4e49"

View File

@ -18,6 +18,7 @@ pub struct FriendlyConfig {
pub key_pem_path: String,
pub name: Option<String>,
pub description: Option<String>,
pub icon_url: Option<String>,
pub contact: Option<String>,
pub public_key_hex: Option<String>,
pub open_relay: bool,
@ -54,6 +55,7 @@ impl Default for FriendlyConfig {
key_pem_path: "/opt/chorus/etc/tls/privkey.pem".to_string(),
name: Some("Chorus Default".to_string()),
description: Some("A default config of the Chorus relay".to_string()),
icon_url: None,
contact: None,
public_key_hex: None,
open_relay: false,
@ -92,6 +94,7 @@ impl FriendlyConfig {
key_pem_path,
name,
description,
icon_url,
contact,
public_key_hex,
open_relay,
@ -150,6 +153,7 @@ impl FriendlyConfig {
key_pem_path,
name,
description,
icon_url,
contact,
public_key,
open_relay,
@ -189,6 +193,7 @@ pub struct Config {
pub key_pem_path: String,
pub name: Option<String>,
pub description: Option<String>,
pub icon_url: Option<String>,
pub contact: Option<String>,
pub public_key: Option<Pubkey>,
pub open_relay: bool,

View File

@ -79,6 +79,12 @@ fn build_rid(config: &Config) -> String {
rid.push_str(description);
rid.push('\"');
}
if let Some(icon_url) = &config.icon_url {
rid.push(',');
rid.push_str("\"icon\":\"");
rid.push_str(icon_url);
rid.push('\"');
}
if let Some(contact) = &config.contact {
rid.push(',');
rid.push_str("\"contact\":\"");