diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-02 17:33:39 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-02 17:33:39 +0000 |
| commit | c07954f44f4c03cc17d4a83b144667cbcbb226cf (patch) | |
| tree | 5372c59bbffe741de0374f41e4a58be7fb61bdef /src/http/nip11.rs | |
| parent | af331ca00da8a3b937c496076f3f7297b3a5283c (diff) | |
nip11 add icon
Diffstat (limited to 'src/http/nip11.rs')
| -rw-r--r-- | src/http/nip11.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/http/nip11.rs b/src/http/nip11.rs index 901b676..ecb9769 100644 --- a/src/http/nip11.rs +++ b/src/http/nip11.rs | |||
| @@ -34,6 +34,10 @@ pub struct RelayInformationDocument { | |||
| 34 | /// Software version | 34 | /// Software version |
| 35 | pub version: String, | 35 | pub version: String, |
| 36 | 36 | ||
| 37 | /// Relay icon URL (NIP-11 optional field) | ||
| 38 | #[serde(skip_serializing_if = "Option::is_none")] | ||
| 39 | pub icon: Option<String>, | ||
| 40 | |||
| 37 | // GRASP-01 Extensions (lines 11-14 of GRASP-01 spec) | 41 | // GRASP-01 Extensions (lines 11-14 of GRASP-01 spec) |
| 38 | /// List of supported GRASPs (e.g., ["GRASP-01"]) | 42 | /// List of supported GRASPs (e.g., ["GRASP-01"]) |
| 39 | /// Required by GRASP-01 specification line 12 | 43 | /// Required by GRASP-01 specification line 12 |
| @@ -67,6 +71,7 @@ impl RelayInformationDocument { | |||
| 67 | Some(commit) => format!("{}-{}", env!("CARGO_PKG_VERSION"), commit), | 71 | Some(commit) => format!("{}-{}", env!("CARGO_PKG_VERSION"), commit), |
| 68 | None => env!("CARGO_PKG_VERSION").to_string(), | 72 | None => env!("CARGO_PKG_VERSION").to_string(), |
| 69 | }, | 73 | }, |
| 74 | icon: Some(format!("https://{}/icon.png", config.domain)), | ||
| 70 | 75 | ||
| 71 | // GRASP-01 Extensions | 76 | // GRASP-01 Extensions |
| 72 | supported_grasps: vec!["GRASP-01".to_string()], | 77 | supported_grasps: vec!["GRASP-01".to_string()], |
| @@ -113,6 +118,10 @@ mod tests { | |||
| 113 | assert_eq!(doc.supported_grasps, vec!["GRASP-01"]); | 118 | assert_eq!(doc.supported_grasps, vec!["GRASP-01"]); |
| 114 | assert!(doc.repo_acceptance_criteria.contains("relay.example.com")); | 119 | assert!(doc.repo_acceptance_criteria.contains("relay.example.com")); |
| 115 | assert!(doc.curation.is_none()); | 120 | assert!(doc.curation.is_none()); |
| 121 | assert_eq!( | ||
| 122 | doc.icon, | ||
| 123 | Some("https://relay.example.com/icon.png".to_string()) | ||
| 124 | ); | ||
| 116 | } | 125 | } |
| 117 | 126 | ||
| 118 | #[test] | 127 | #[test] |
| @@ -143,5 +152,6 @@ mod tests { | |||
| 143 | let parsed: serde_json::Value = serde_json::from_str(&json).expect("Invalid JSON"); | 152 | let parsed: serde_json::Value = serde_json::from_str(&json).expect("Invalid JSON"); |
| 144 | assert_eq!(parsed["name"], "Test Relay"); | 153 | assert_eq!(parsed["name"], "Test Relay"); |
| 145 | assert_eq!(parsed["supported_grasps"][0], "GRASP-01"); | 154 | assert_eq!(parsed["supported_grasps"][0], "GRASP-01"); |
| 155 | assert_eq!(parsed["icon"], "https://relay.example.com/icon.png"); | ||
| 146 | } | 156 | } |
| 147 | } | 157 | } |