diff --git a/config/default.toml b/config/default.toml index dbb2c92..e1adb83 100644 --- a/config/default.toml +++ b/config/default.toml @@ -55,7 +55,7 @@ client_id = "WlVrcm4xSEpXQ2l3TURFM3lLZnE6MTpjaQ" client_secret = "lfXc45dZLqYTzP62Ms32EhXinGQzxcIP9TvjJml2B-h0T1nIJK" [x_association] -bio_mention = "@QuantusNetwork" +keywords = "Quantus" [tweet_sync] api_key = "some-key" diff --git a/config/example.toml b/config/example.toml index 98869a9..7689423 100644 --- a/config/example.toml +++ b/config/example.toml @@ -65,7 +65,7 @@ client_id = "example-id" client_secret = "example-secret" [x_association] -bio_mention = "@QuantusNetwork" +keywords = "Quantus" [tweet_sync] api_key = "some-key" diff --git a/config/test.toml b/config/test.toml index 47327b2..174c186 100644 --- a/config/test.toml +++ b/config/test.toml @@ -55,7 +55,7 @@ client_id = "test-id" client_secret = "test-secret" [x_association] -bio_mention = "@QuantusNetwork" +keywords = "Quantus" [tweet_sync] api_key = "some-key" diff --git a/src/config.rs b/src/config.rs index 7ff2ad5..be250af 100644 --- a/src/config.rs +++ b/src/config.rs @@ -88,7 +88,7 @@ pub struct AlertConfig { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct XAssociationConfig { - pub bio_mention: String, + pub keywords: String, } impl Config { @@ -142,8 +142,8 @@ impl Config { time::Duration::from_secs(self.raid_leaderboard.tweets_req_interval_in_secs) } - pub fn get_x_bio_mention(&self) -> &str { - &self.x_association.bio_mention + pub fn get_x_association_keywords(&self) -> &str { + &self.x_association.keywords } } @@ -204,7 +204,7 @@ impl Default for Config { webhook_url: "https://your-webhook-url.com".to_string(), }, x_association: XAssociationConfig { - bio_mention: "@QuantusNetwork".to_string(), + keywords: "Quantus".to_string(), }, } } diff --git a/src/handlers/address.rs b/src/handlers/address.rs index 0fced40..34e8f5c 100644 --- a/src/handlers/address.rs +++ b/src/handlers/address.rs @@ -258,13 +258,13 @@ pub async fn associate_x_handle( ))) })?; - let bio = twitter_user.description.unwrap_or_default(); - let x_bio_mention = state.config.get_x_bio_mention(); - if !bio.to_lowercase().contains(&x_bio_mention.to_lowercase()) { + let name = twitter_user.name; + let x_association_keywords = state.config.get_x_association_keywords(); + if !name.to_lowercase().contains(&x_association_keywords.to_lowercase()) { return Err(AppError::Handler(HandlerError::Address( AddressHandlerError::Unauthorized(format!( - "Twitter bio must contain '{}' to verify ownership", - x_bio_mention + "Twitter name must contain '{}' to verify ownership", + x_association_keywords )), ))); } @@ -431,14 +431,14 @@ mod tests { let mut mock_user_api = MockUserApi::new(); // Expect get_by_username - let bio_mention = state.config.get_x_bio_mention().to_string(); + let x_association_keywords = state.config.get_x_association_keywords().to_string(); mock_user_api.expect_get_by_username().returning(move |_, _| { Ok(TwitterApiResponse { data: Some(User { id: "u1".to_string(), - name: "Test User".to_string(), + name: format!("Test User {}", x_association_keywords), username: "test_user".to_string(), - description: Some(format!("I love {}", bio_mention)), // Contains keyword from config + description: Some(format!("I love {}", x_association_keywords)), // Contains keyword from config public_metrics: None, }), includes: None, @@ -552,17 +552,17 @@ mod tests { let mut mock_user_api = MockUserApi::new(); // Expect get_by_username - let bio_mention = state.config.get_x_bio_mention().to_string(); + let x_association_keywords = state.config.get_x_association_keywords().to_string(); // Create a lowercase version of the mention for the bio - let lowercase_bio_mention = bio_mention.to_lowercase(); + let lowercase_x_association_keywords = x_association_keywords.to_lowercase(); mock_user_api.expect_get_by_username().returning(move |_, _| { Ok(TwitterApiResponse { data: Some(User { id: "u1".to_string(), - name: "Test User".to_string(), + name: format!("Test User {}", lowercase_x_association_keywords), username: "test_user".to_string(), - description: Some(format!("I love {}", lowercase_bio_mention)), // Contains lowercase keyword + description: Some(format!("I love {}", lowercase_x_association_keywords)), // Contains lowercase keyword public_metrics: None, }), includes: None,