diff options
Diffstat (limited to 'src/http/nip11.rs')
| -rw-r--r-- | src/http/nip11.rs | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/src/http/nip11.rs b/src/http/nip11.rs index ff7b8df..7c58175 100644 --- a/src/http/nip11.rs +++ b/src/http/nip11.rs | |||
| @@ -56,16 +56,10 @@ pub struct RelayInformationDocument { | |||
| 56 | impl RelayInformationDocument { | 56 | impl RelayInformationDocument { |
| 57 | /// Create NIP-11 relay information document from configuration | 57 | /// Create NIP-11 relay information document from configuration |
| 58 | pub fn from_config(config: &Config) -> Self { | 58 | pub fn from_config(config: &Config) -> Self { |
| 59 | // Determine if archive mode is enabled | 59 | // Get validated configuration (config.validate() must be called at startup) |
| 60 | let archive_config = config.archive_config().ok(); | 60 | let archive_config = config.archive_config(); |
| 61 | let archive_enabled = archive_config | 61 | let archive_enabled = archive_config.enabled(); |
| 62 | .as_ref() | 62 | let archive_read_only = archive_config.read_only; |
| 63 | .map(|ac| ac.enabled()) | ||
| 64 | .unwrap_or(false); | ||
| 65 | let archive_read_only = archive_config | ||
| 66 | .as_ref() | ||
| 67 | .map(|ac| ac.read_only) | ||
| 68 | .unwrap_or(false); | ||
| 69 | 63 | ||
| 70 | // Build supported_grasps list | 64 | // Build supported_grasps list |
| 71 | let mut supported_grasps = vec!["GRASP-01".to_string()]; | 65 | let mut supported_grasps = vec!["GRASP-01".to_string()]; |
| @@ -75,22 +69,15 @@ impl RelayInformationDocument { | |||
| 75 | supported_grasps.push("GRASP-02".to_string()); | 69 | supported_grasps.push("GRASP-02".to_string()); |
| 76 | 70 | ||
| 77 | // Build curation field for archive read-only mode or repository whitelist | 71 | // Build curation field for archive read-only mode or repository whitelist |
| 78 | let repository_config = config.repository_config().ok(); | 72 | let repository_config = config.repository_config(); |
| 79 | let repository_whitelist_enabled = repository_config | 73 | let repository_whitelist_enabled = repository_config.enabled(); |
| 80 | .as_ref() | ||
| 81 | .map(|rc| rc.enabled()) | ||
| 82 | .unwrap_or(false); | ||
| 83 | 74 | ||
| 84 | let curation = if archive_read_only { | 75 | let curation = if archive_read_only { |
| 85 | // Archive read-only mode (GRASP-05 only) | 76 | // Archive read-only mode (GRASP-05 only) |
| 86 | if let Some(ref ac) = archive_config { | 77 | if archive_config.archive_all { |
| 87 | if ac.archive_all { | 78 | Some("Read-only sync of all repositories found on network".to_string()) |
| 88 | Some("Read-only sync of all repositories found on network".to_string()) | 79 | } else if !archive_config.whitelist.is_empty() { |
| 89 | } else if !ac.whitelist.is_empty() { | 80 | Some("Read-only sync of whitelisted repositories and maintainers".to_string()) |
| 90 | Some("Read-only sync of whitelisted repositories and maintainers".to_string()) | ||
| 91 | } else { | ||
| 92 | None | ||
| 93 | } | ||
| 94 | } else { | 81 | } else { |
| 95 | None | 82 | None |
| 96 | } | 83 | } |