From 455aac66f80d72ad192f32aa5390fb5d010e01a9 Mon Sep 17 00:00:00 2001 From: Beast Date: Tue, 20 Jan 2026 17:56:44 +0800 Subject: [PATCH] feat: make x association to check bio instead --- config/default.toml | 2 +- config/example.toml | 2 +- config/test.toml | 2 +- src/handlers/address.rs | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/default.toml b/config/default.toml index 63f00a2..29c7da8 100644 --- a/config/default.toml +++ b/config/default.toml @@ -55,7 +55,7 @@ client_id = "WlVrcm4xSEpXQ2l3TURFM3lLZnE6MTpjaQ" client_secret = "lfXc45dZLqYTzP62Ms32EhXinGQzxcIP9TvjJml2B-h0T1nIJK" [x_association] -keywords = "quantus" +keywords = "@quantusnetwork" [tweet_sync] api_key = "some-key" diff --git a/config/example.toml b/config/example.toml index 408b234..5da59ba 100644 --- a/config/example.toml +++ b/config/example.toml @@ -65,7 +65,7 @@ client_id = "example-id" client_secret = "example-secret" [x_association] -keywords = "quantus" +keywords = "@quantusnetwork" [tweet_sync] api_key = "some-key" diff --git a/config/test.toml b/config/test.toml index 9e669e5..9e11ffd 100644 --- a/config/test.toml +++ b/config/test.toml @@ -55,7 +55,7 @@ client_id = "test-id" client_secret = "test-secret" [x_association] -keywords = "quantus" +keywords = "@quantusnetwork" [tweet_sync] api_key = "some-key" diff --git a/src/handlers/address.rs b/src/handlers/address.rs index 34e8f5c..52c7c06 100644 --- a/src/handlers/address.rs +++ b/src/handlers/address.rs @@ -258,12 +258,12 @@ pub async fn associate_x_handle( ))) })?; - let name = twitter_user.name; + let bio = twitter_user.description.unwrap_or_default(); let x_association_keywords = state.config.get_x_association_keywords(); - if !name.to_lowercase().contains(&x_association_keywords.to_lowercase()) { + if !bio.to_lowercase().contains(&x_association_keywords.to_lowercase()) { return Err(AppError::Handler(HandlerError::Address( AddressHandlerError::Unauthorized(format!( - "Twitter name must contain '{}' to verify ownership", + "Twitter bio must mention '{}' to verify ownership", x_association_keywords )), ))); @@ -436,7 +436,7 @@ mod tests { Ok(TwitterApiResponse { data: Some(User { id: "u1".to_string(), - name: format!("Test User {}", x_association_keywords), + name: "Test User".to_string(), username: "test_user".to_string(), description: Some(format!("I love {}", x_association_keywords)), // Contains keyword from config public_metrics: None,