mirror of
https://relay.ngit.dev/npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/ngit-grasp.git
synced 2026-10-05 23:18:24 +00:00
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
This commit is contained in:
+5
-39
@@ -109,7 +109,7 @@ impl WhitelistEntry {
|
||||
}
|
||||
|
||||
/// GRASP-05 Archive mode configuration
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct ArchiveConfig {
|
||||
/// Accept all repository announcements (no filtering)
|
||||
///
|
||||
@@ -146,6 +146,7 @@ impl ArchiveConfig {
|
||||
/// Returns true if:
|
||||
/// - archive_all is true, OR
|
||||
/// - announcement matches any whitelist entry
|
||||
///
|
||||
/// Note: grasp_services matching is handled via matches_grasp_services()
|
||||
pub fn matches(&self, npub: &str, identifier: &str) -> bool {
|
||||
if self.archive_all {
|
||||
@@ -171,19 +172,8 @@ impl ArchiveConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ArchiveConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
archive_all: false,
|
||||
whitelist: Vec::new(),
|
||||
grasp_services: Vec::new(),
|
||||
read_only: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Repository whitelist configuration
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct RepositoryConfig {
|
||||
/// Whitelist entries for selective repository acceptance
|
||||
///
|
||||
@@ -207,16 +197,8 @@ impl RepositoryConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for RepositoryConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
whitelist: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Repository blacklist configuration
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct BlacklistConfig {
|
||||
/// Blacklist entries for blocking specific repositories
|
||||
///
|
||||
@@ -256,16 +238,8 @@ impl BlacklistConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for BlacklistConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
blacklist: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Event blacklist configuration for blocking events by author npub
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct EventBlacklistConfig {
|
||||
/// Blacklisted npubs - events from these authors are rejected
|
||||
///
|
||||
@@ -292,14 +266,6 @@ impl EventBlacklistConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for EventBlacklistConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
blacklisted_npubs: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Database backend type for the relay
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default, ValueEnum)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
|
||||
+7
-7
@@ -419,14 +419,14 @@ pub fn validate_announcement(
|
||||
// GRASP-01: Normal mode - accept if announcement lists our service AND matches repository whitelist (if enabled)
|
||||
if lists_service && !archive_config.read_only {
|
||||
// Check repository whitelist if enabled
|
||||
if repository_config.enabled() {
|
||||
if !repository_config.matches(&npub, &announcement.identifier) {
|
||||
return AnnouncementResult::Reject(format!(
|
||||
"Announcement lists service but does not match repository whitelist. \
|
||||
if repository_config.enabled()
|
||||
&& !repository_config.matches(&npub, &announcement.identifier)
|
||||
{
|
||||
return AnnouncementResult::Reject(format!(
|
||||
"Announcement lists service but does not match repository whitelist. \
|
||||
Repository {}/{} not in whitelist",
|
||||
npub, announcement.identifier
|
||||
));
|
||||
}
|
||||
npub, announcement.identifier
|
||||
));
|
||||
}
|
||||
return AnnouncementResult::Accept;
|
||||
}
|
||||
|
||||
@@ -584,6 +584,7 @@ impl SyncManager {
|
||||
/// * `config` - Configuration for sync settings
|
||||
/// * `data_path` - Path to git data directory (for persistence)
|
||||
/// * `sync_metrics` - Optional pre-registered SyncMetrics (passed from Metrics if metrics are enabled)
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
bootstrap_relay_url: Option<String>,
|
||||
service_domain: String,
|
||||
|
||||
Reference in New Issue
Block a user