upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-12 14:02:22 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-12 14:50:53 +0000
commit8fc4078d60f0ccf16318fe7fa765fcdd3627fe1f (patch)
treeb8af6ea023d2fbdd400a18d90a8d7ffe1bee4d57
parent71b6157044f305c8d7142b24bd71798035603f0e (diff)
chore: fix clippy warnings
- Derive Default for config structs instead of manual impl - Fix doc comment formatting in ArchiveConfig::matches - Collapse nested if statement in validate_announcement - Allow too_many_arguments for SyncManager::new
-rw-r--r--src/config.rs44
-rw-r--r--src/nostr/events.rs14
-rw-r--r--src/sync/mod.rs1
3 files changed, 13 insertions, 46 deletions
diff --git a/src/config.rs b/src/config.rs
index 271a340..7062187 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -109,7 +109,7 @@ impl WhitelistEntry {
109} 109}
110 110
111/// GRASP-05 Archive mode configuration 111/// GRASP-05 Archive mode configuration
112#[derive(Debug, Clone, Serialize, Deserialize)] 112#[derive(Debug, Clone, Serialize, Deserialize, Default)]
113pub struct ArchiveConfig { 113pub struct ArchiveConfig {
114 /// Accept all repository announcements (no filtering) 114 /// Accept all repository announcements (no filtering)
115 /// 115 ///
@@ -146,6 +146,7 @@ impl ArchiveConfig {
146 /// Returns true if: 146 /// Returns true if:
147 /// - archive_all is true, OR 147 /// - archive_all is true, OR
148 /// - announcement matches any whitelist entry 148 /// - announcement matches any whitelist entry
149 ///
149 /// Note: grasp_services matching is handled via matches_grasp_services() 150 /// Note: grasp_services matching is handled via matches_grasp_services()
150 pub fn matches(&self, npub: &str, identifier: &str) -> bool { 151 pub fn matches(&self, npub: &str, identifier: &str) -> bool {
151 if self.archive_all { 152 if self.archive_all {
@@ -171,19 +172,8 @@ impl ArchiveConfig {
171 } 172 }
172} 173}
173 174
174impl Default for ArchiveConfig {
175 fn default() -> Self {
176 Self {
177 archive_all: false,
178 whitelist: Vec::new(),
179 grasp_services: Vec::new(),
180 read_only: false,
181 }
182 }
183}
184
185/// Repository whitelist configuration 175/// Repository whitelist configuration
186#[derive(Debug, Clone, Serialize, Deserialize)] 176#[derive(Debug, Clone, Serialize, Deserialize, Default)]
187pub struct RepositoryConfig { 177pub struct RepositoryConfig {
188 /// Whitelist entries for selective repository acceptance 178 /// Whitelist entries for selective repository acceptance
189 /// 179 ///
@@ -207,16 +197,8 @@ impl RepositoryConfig {
207 } 197 }
208} 198}
209 199
210impl Default for RepositoryConfig {
211 fn default() -> Self {
212 Self {
213 whitelist: Vec::new(),
214 }
215 }
216}
217
218/// Repository blacklist configuration 200/// Repository blacklist configuration
219#[derive(Debug, Clone, Serialize, Deserialize)] 201#[derive(Debug, Clone, Serialize, Deserialize, Default)]
220pub struct BlacklistConfig { 202pub struct BlacklistConfig {
221 /// Blacklist entries for blocking specific repositories 203 /// Blacklist entries for blocking specific repositories
222 /// 204 ///
@@ -256,16 +238,8 @@ impl BlacklistConfig {
256 } 238 }
257} 239}
258 240
259impl Default for BlacklistConfig {
260 fn default() -> Self {
261 Self {
262 blacklist: Vec::new(),
263 }
264 }
265}
266
267/// Event blacklist configuration for blocking events by author npub 241/// Event blacklist configuration for blocking events by author npub
268#[derive(Debug, Clone, Serialize, Deserialize)] 242#[derive(Debug, Clone, Serialize, Deserialize, Default)]
269pub struct EventBlacklistConfig { 243pub struct EventBlacklistConfig {
270 /// Blacklisted npubs - events from these authors are rejected 244 /// Blacklisted npubs - events from these authors are rejected
271 /// 245 ///
@@ -292,14 +266,6 @@ impl EventBlacklistConfig {
292 } 266 }
293} 267}
294 268
295impl Default for EventBlacklistConfig {
296 fn default() -> Self {
297 Self {
298 blacklisted_npubs: Vec::new(),
299 }
300 }
301}
302
303/// Database backend type for the relay 269/// Database backend type for the relay
304#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default, ValueEnum)] 270#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default, ValueEnum)]
305#[serde(rename_all = "lowercase")] 271#[serde(rename_all = "lowercase")]
diff --git a/src/nostr/events.rs b/src/nostr/events.rs
index 718633e..b9784f7 100644
--- a/src/nostr/events.rs
+++ b/src/nostr/events.rs
@@ -419,14 +419,14 @@ pub fn validate_announcement(
419 // GRASP-01: Normal mode - accept if announcement lists our service AND matches repository whitelist (if enabled) 419 // GRASP-01: Normal mode - accept if announcement lists our service AND matches repository whitelist (if enabled)
420 if lists_service && !archive_config.read_only { 420 if lists_service && !archive_config.read_only {
421 // Check repository whitelist if enabled 421 // Check repository whitelist if enabled
422 if repository_config.enabled() { 422 if repository_config.enabled()
423 if !repository_config.matches(&npub, &announcement.identifier) { 423 && !repository_config.matches(&npub, &announcement.identifier)
424 return AnnouncementResult::Reject(format!( 424 {
425 "Announcement lists service but does not match repository whitelist. \ 425 return AnnouncementResult::Reject(format!(
426 "Announcement lists service but does not match repository whitelist. \
426 Repository {}/{} not in whitelist", 427 Repository {}/{} not in whitelist",
427 npub, announcement.identifier 428 npub, announcement.identifier
428 )); 429 ));
429 }
430 } 430 }
431 return AnnouncementResult::Accept; 431 return AnnouncementResult::Accept;
432 } 432 }
diff --git a/src/sync/mod.rs b/src/sync/mod.rs
index bc8c428..1ee1872 100644
--- a/src/sync/mod.rs
+++ b/src/sync/mod.rs
@@ -584,6 +584,7 @@ impl SyncManager {
584 /// * `config` - Configuration for sync settings 584 /// * `config` - Configuration for sync settings
585 /// * `data_path` - Path to git data directory (for persistence) 585 /// * `data_path` - Path to git data directory (for persistence)
586 /// * `sync_metrics` - Optional pre-registered SyncMetrics (passed from Metrics if metrics are enabled) 586 /// * `sync_metrics` - Optional pre-registered SyncMetrics (passed from Metrics if metrics are enabled)
587 #[allow(clippy::too_many_arguments)]
587 pub fn new( 588 pub fn new(
588 bootstrap_relay_url: Option<String>, 589 bootstrap_relay_url: Option<String>,
589 service_domain: String, 590 service_domain: String,