fix: resolve clippy uninlined_format_args in integrations and related modules
Replace format!("msg: {}", var) with format!("msg: {var}") across 8 files
to satisfy the uninlined_format_args lint (-D warnings) in CI run 178.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
64492c743b
commit
bdb63f3aee
@ -97,9 +97,9 @@ mod tests {
|
||||
for i in 0..5 {
|
||||
write_audit_event(
|
||||
&conn,
|
||||
&format!("action_{}", i),
|
||||
&format!("action_{i}"),
|
||||
"test",
|
||||
&format!("id_{}", i),
|
||||
&format!("id_{i}"),
|
||||
"{}",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -94,7 +94,7 @@ pub async fn initiate_oauth(
|
||||
let (mut callback_rx, shutdown_tx) =
|
||||
crate::integrations::callback_server::start_callback_server(8765)
|
||||
.await
|
||||
.map_err(|e| format!("Failed to start callback server: {}", e))?;
|
||||
.map_err(|e| format!("Failed to start callback server: {e}"))?;
|
||||
|
||||
// Store shutdown channel
|
||||
{
|
||||
@ -123,7 +123,7 @@ pub async fn initiate_oauth(
|
||||
let mut oauth_state = match OAUTH_STATE.lock() {
|
||||
Ok(state) => state,
|
||||
Err(e) => {
|
||||
tracing::error!("Failed to lock OAuth state: {}", e);
|
||||
tracing::error!("Failed to lock OAuth state: {e}");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
@ -148,7 +148,7 @@ pub async fn initiate_oauth(
|
||||
|
||||
match result {
|
||||
Ok(_) => tracing::info!("OAuth callback handled successfully"),
|
||||
Err(e) => tracing::error!("OAuth callback failed: {}", e),
|
||||
Err(e) => tracing::error!("OAuth callback failed: {e}"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ pub async fn initiate_oauth(
|
||||
{
|
||||
let mut oauth_state = OAUTH_STATE
|
||||
.lock()
|
||||
.map_err(|e| format!("Failed to lock OAuth state: {}", e))?;
|
||||
.map_err(|e| format!("Failed to lock OAuth state: {e}"))?;
|
||||
oauth_state.insert(
|
||||
state_key.clone(),
|
||||
(service.clone(), pkce.code_verifier.clone()),
|
||||
@ -193,7 +193,7 @@ pub async fn initiate_oauth(
|
||||
// ServiceNow uses basic auth, not OAuth2
|
||||
return Err("ServiceNow uses basic authentication, not OAuth2".to_string());
|
||||
}
|
||||
_ => return Err(format!("Unknown service: {}", service)),
|
||||
_ => return Err(format!("Unknown service: {service}")),
|
||||
};
|
||||
|
||||
let auth_url = crate::integrations::auth::build_auth_url(
|
||||
@ -231,7 +231,7 @@ async fn handle_oauth_callback_internal(
|
||||
.unwrap_or_else(|_| "ado-client-id-placeholder".to_string()),
|
||||
"http://localhost:8765/callback",
|
||||
),
|
||||
_ => return Err(format!("Unknown service: {}", service)),
|
||||
_ => return Err(format!("Unknown service: {service}")),
|
||||
};
|
||||
|
||||
// Exchange authorization code for access token
|
||||
@ -265,7 +265,7 @@ async fn handle_oauth_callback_internal(
|
||||
let db = app_state
|
||||
.db
|
||||
.lock()
|
||||
.map_err(|e| format!("Failed to lock database: {}", e))?;
|
||||
.map_err(|e| format!("Failed to lock database: {e}"))?;
|
||||
|
||||
db.execute(
|
||||
"INSERT OR REPLACE INTO credentials (id, service, token_hash, encrypted_token, created_at, expires_at)
|
||||
@ -279,7 +279,7 @@ async fn handle_oauth_callback_internal(
|
||||
expires_at,
|
||||
],
|
||||
)
|
||||
.map_err(|e| format!("Failed to store credentials: {}", e))?;
|
||||
.map_err(|e| format!("Failed to store credentials: {e}"))?;
|
||||
|
||||
// Log audit event
|
||||
let audit_details = serde_json::json!({
|
||||
@ -301,7 +301,7 @@ async fn handle_oauth_callback_internal(
|
||||
audit_details.to_string(),
|
||||
],
|
||||
)
|
||||
.map_err(|e| format!("Failed to log audit event: {}", e))?;
|
||||
.map_err(|e| format!("Failed to log audit event: {e}"))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -319,7 +319,7 @@ pub async fn handle_oauth_callback(
|
||||
let verifier = {
|
||||
let mut oauth_state = OAUTH_STATE
|
||||
.lock()
|
||||
.map_err(|e| format!("Failed to lock OAuth state: {}", e))?;
|
||||
.map_err(|e| format!("Failed to lock OAuth state: {e}"))?;
|
||||
oauth_state
|
||||
.remove(&state_key)
|
||||
.map(|(_svc, ver)| ver)
|
||||
@ -520,7 +520,7 @@ pub async fn authenticate_with_webview(
|
||||
if let Some(existing_label) = app_state
|
||||
.integration_webviews
|
||||
.lock()
|
||||
.map_err(|e| format!("Failed to lock webviews: {}", e))?
|
||||
.map_err(|e| format!("Failed to lock webviews: {e}"))?
|
||||
.get(&service)
|
||||
{
|
||||
if app_handle.get_webview_window(existing_label).is_some() {
|
||||
@ -545,7 +545,7 @@ pub async fn authenticate_with_webview(
|
||||
app_state
|
||||
.integration_webviews
|
||||
.lock()
|
||||
.map_err(|e| format!("Failed to lock webviews: {}", e))?
|
||||
.map_err(|e| format!("Failed to lock webviews: {e}"))?
|
||||
.insert(service.clone(), webview_id.clone());
|
||||
|
||||
Ok(WebviewAuthResponse {
|
||||
@ -582,8 +582,8 @@ pub async fn extract_cookies_from_webview(
|
||||
}
|
||||
|
||||
// Encrypt and store cookies in database
|
||||
let cookies_json = serde_json::to_string(&cookies)
|
||||
.map_err(|e| format!("Failed to serialize cookies: {}", e))?;
|
||||
let cookies_json =
|
||||
serde_json::to_string(&cookies).map_err(|e| format!("Failed to serialize cookies: {e}"))?;
|
||||
let encrypted_cookies = crate::integrations::auth::encrypt_token(&cookies_json)?;
|
||||
|
||||
let token_hash = {
|
||||
@ -597,7 +597,7 @@ pub async fn extract_cookies_from_webview(
|
||||
let db = app_state
|
||||
.db
|
||||
.lock()
|
||||
.map_err(|e| format!("Failed to lock database: {}", e))?;
|
||||
.map_err(|e| format!("Failed to lock database: {e}"))?;
|
||||
|
||||
db.execute(
|
||||
"INSERT OR REPLACE INTO credentials (id, service, token_hash, encrypted_token, created_at, expires_at)
|
||||
@ -611,13 +611,13 @@ pub async fn extract_cookies_from_webview(
|
||||
None::<String>, // Cookies don't have explicit expiry
|
||||
],
|
||||
)
|
||||
.map_err(|e| format!("Failed to store cookies: {}", e))?;
|
||||
.map_err(|e| format!("Failed to store cookies: {e}"))?;
|
||||
|
||||
// Close the webview window
|
||||
if let Some(webview) = app_handle.get_webview_window(&webview_id) {
|
||||
webview
|
||||
.close()
|
||||
.map_err(|e| format!("Failed to close webview: {}", e))?;
|
||||
.map_err(|e| format!("Failed to close webview: {e}"))?;
|
||||
}
|
||||
|
||||
Ok(ConnectionResult {
|
||||
@ -698,7 +698,7 @@ pub async fn save_manual_token(
|
||||
let db = app_state
|
||||
.db
|
||||
.lock()
|
||||
.map_err(|e| format!("Failed to lock database: {}", e))?;
|
||||
.map_err(|e| format!("Failed to lock database: {e}"))?;
|
||||
|
||||
db.execute(
|
||||
"INSERT OR REPLACE INTO credentials (id, service, token_hash, encrypted_token, created_at, expires_at)
|
||||
@ -712,7 +712,7 @@ pub async fn save_manual_token(
|
||||
None::<String>,
|
||||
],
|
||||
)
|
||||
.map_err(|e| format!("Failed to store token: {}", e))?;
|
||||
.map_err(|e| format!("Failed to store token: {e}"))?;
|
||||
|
||||
// Log audit event
|
||||
db.execute(
|
||||
@ -732,7 +732,7 @@ pub async fn save_manual_token(
|
||||
.to_string(),
|
||||
],
|
||||
)
|
||||
.map_err(|e| format!("Failed to log audit event: {}", e))?;
|
||||
.map_err(|e| format!("Failed to log audit event: {e}"))?;
|
||||
|
||||
Ok(ConnectionResult {
|
||||
success: true,
|
||||
@ -757,7 +757,7 @@ pub async fn get_fresh_cookies_from_webview(
|
||||
let webviews = app_state
|
||||
.integration_webviews
|
||||
.lock()
|
||||
.map_err(|e| format!("Failed to lock webviews: {}", e))?;
|
||||
.map_err(|e| format!("Failed to lock webviews: {e}"))?;
|
||||
|
||||
match webviews.get(service) {
|
||||
Some(label) => label.clone(),
|
||||
@ -773,7 +773,7 @@ pub async fn get_fresh_cookies_from_webview(
|
||||
app_state
|
||||
.integration_webviews
|
||||
.lock()
|
||||
.map_err(|e| format!("Failed to lock webviews: {}", e))?
|
||||
.map_err(|e| format!("Failed to lock webviews: {e}"))?
|
||||
.remove(service);
|
||||
return Ok(None);
|
||||
}
|
||||
@ -814,7 +814,7 @@ pub async fn save_integration_config(
|
||||
let db = app_state
|
||||
.db
|
||||
.lock()
|
||||
.map_err(|e| format!("Failed to lock database: {}", e))?;
|
||||
.map_err(|e| format!("Failed to lock database: {e}"))?;
|
||||
|
||||
db.execute(
|
||||
"INSERT OR REPLACE INTO integration_config
|
||||
@ -829,7 +829,7 @@ pub async fn save_integration_config(
|
||||
config.space_key,
|
||||
],
|
||||
)
|
||||
.map_err(|e| format!("Failed to save integration config: {}", e))?;
|
||||
.map_err(|e| format!("Failed to save integration config: {e}"))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -843,11 +843,11 @@ pub async fn get_integration_config(
|
||||
let db = app_state
|
||||
.db
|
||||
.lock()
|
||||
.map_err(|e| format!("Failed to lock database: {}", e))?;
|
||||
.map_err(|e| format!("Failed to lock database: {e}"))?;
|
||||
|
||||
let mut stmt = db
|
||||
.prepare("SELECT service, base_url, username, project_name, space_key FROM integration_config WHERE service = ?1")
|
||||
.map_err(|e| format!("Failed to prepare query: {}", e))?;
|
||||
.map_err(|e| format!("Failed to prepare query: {e}"))?;
|
||||
|
||||
let config = stmt
|
||||
.query_row([&service], |row| {
|
||||
@ -860,7 +860,7 @@ pub async fn get_integration_config(
|
||||
})
|
||||
})
|
||||
.optional()
|
||||
.map_err(|e| format!("Failed to query integration config: {}", e))?;
|
||||
.map_err(|e| format!("Failed to query integration config: {e}"))?;
|
||||
|
||||
Ok(config)
|
||||
}
|
||||
@ -873,13 +873,13 @@ pub async fn get_all_integration_configs(
|
||||
let db = app_state
|
||||
.db
|
||||
.lock()
|
||||
.map_err(|e| format!("Failed to lock database: {}", e))?;
|
||||
.map_err(|e| format!("Failed to lock database: {e}"))?;
|
||||
|
||||
let mut stmt = db
|
||||
.prepare(
|
||||
"SELECT service, base_url, username, project_name, space_key FROM integration_config",
|
||||
)
|
||||
.map_err(|e| format!("Failed to prepare query: {}", e))?;
|
||||
.map_err(|e| format!("Failed to prepare query: {e}"))?;
|
||||
|
||||
let configs = stmt
|
||||
.query_map([], |row| {
|
||||
@ -891,9 +891,9 @@ pub async fn get_all_integration_configs(
|
||||
space_key: row.get(4)?,
|
||||
})
|
||||
})
|
||||
.map_err(|e| format!("Failed to query integration configs: {}", e))?
|
||||
.map_err(|e| format!("Failed to query integration configs: {e}"))?
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map_err(|e| format!("Failed to collect integration configs: {}", e))?;
|
||||
.map_err(|e| format!("Failed to collect integration configs: {e}"))?;
|
||||
|
||||
Ok(configs)
|
||||
}
|
||||
|
||||
@ -162,13 +162,13 @@ pub fn run_migrations(conn: &Connection) -> anyhow::Result<()> {
|
||||
// FTS5 virtual table creation can be skipped if FTS5 is not compiled in
|
||||
if let Err(e) = conn.execute_batch(sql) {
|
||||
if name.contains("fts") {
|
||||
tracing::warn!("FTS5 not available, skipping: {}", e);
|
||||
tracing::warn!("FTS5 not available, skipping: {e}");
|
||||
} else {
|
||||
return Err(e.into());
|
||||
}
|
||||
}
|
||||
conn.execute("INSERT INTO _migrations (name) VALUES (?1)", [name])?;
|
||||
tracing::info!("Applied migration: {}", name);
|
||||
tracing::info!("Applied migration: {name}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ pub async fn exchange_code(
|
||||
.form(¶ms)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to send token exchange request: {}", e))?;
|
||||
.map_err(|e| format!("Failed to send token exchange request: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -101,7 +101,7 @@ pub async fn exchange_code(
|
||||
let body: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse token response: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse token response: {e}"))?;
|
||||
|
||||
let access_token = body["access_token"]
|
||||
.as_str()
|
||||
@ -208,7 +208,7 @@ pub fn encrypt_token(token: &str) -> Result<String, String> {
|
||||
// Encrypt
|
||||
let ciphertext = cipher
|
||||
.encrypt(nonce, token.as_bytes())
|
||||
.map_err(|e| format!("Encryption failed: {}", e))?;
|
||||
.map_err(|e| format!("Encryption failed: {e}"))?;
|
||||
|
||||
// Prepend nonce to ciphertext
|
||||
let mut result = nonce_bytes.to_vec();
|
||||
@ -232,7 +232,7 @@ pub fn decrypt_token(encrypted: &str) -> Result<String, String> {
|
||||
use base64::Engine;
|
||||
let data = STANDARD
|
||||
.decode(encrypted)
|
||||
.map_err(|e| format!("Base64 decode failed: {}", e))?;
|
||||
.map_err(|e| format!("Base64 decode failed: {e}"))?;
|
||||
|
||||
if data.len() < 12 {
|
||||
return Err("Invalid encrypted data: too short".to_string());
|
||||
@ -256,9 +256,9 @@ pub fn decrypt_token(encrypted: &str) -> Result<String, String> {
|
||||
// Decrypt
|
||||
let plaintext = cipher
|
||||
.decrypt(nonce, ciphertext)
|
||||
.map_err(|e| format!("Decryption failed: {}", e))?;
|
||||
.map_err(|e| format!("Decryption failed: {e}"))?;
|
||||
|
||||
String::from_utf8(plaintext).map_err(|e| format!("Invalid UTF-8: {}", e))
|
||||
String::from_utf8(plaintext).map_err(|e| format!("Invalid UTF-8: {e}"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@ -32,7 +32,7 @@ pub async fn test_connection(config: &AzureDevOpsConfig) -> Result<ConnectionRes
|
||||
.bearer_auth(&config.access_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Connection failed: {}", e))?;
|
||||
.map_err(|e| format!("Connection failed: {e}"))?;
|
||||
|
||||
if resp.status().is_success() {
|
||||
Ok(ConnectionResult {
|
||||
@ -74,7 +74,7 @@ pub async fn search_work_items(
|
||||
.json(&body)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("WIQL query failed: {}", e))?;
|
||||
.map_err(|e| format!("WIQL query failed: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -87,7 +87,7 @@ pub async fn search_work_items(
|
||||
let wiql_result: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse WIQL response: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse WIQL response: {e}"))?;
|
||||
|
||||
let work_item_refs = wiql_result["workItems"]
|
||||
.as_array()
|
||||
@ -119,7 +119,7 @@ pub async fn search_work_items(
|
||||
.bearer_auth(&config.access_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to fetch work item details: {}", e))?;
|
||||
.map_err(|e| format!("Failed to fetch work item details: {e}"))?;
|
||||
|
||||
if !detail_resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -131,7 +131,7 @@ pub async fn search_work_items(
|
||||
let details: serde_json::Value = detail_resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse work item details: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse work item details: {e}"))?;
|
||||
|
||||
let work_items = details["value"]
|
||||
.as_array()
|
||||
@ -199,7 +199,7 @@ pub async fn create_work_item(
|
||||
.json(&operations)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to create work item: {}", e))?;
|
||||
.map_err(|e| format!("Failed to create work item: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -212,7 +212,7 @@ pub async fn create_work_item(
|
||||
let result: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse response: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse response: {e}"))?;
|
||||
|
||||
let work_item_id = result["id"].as_i64().unwrap_or(0);
|
||||
let work_item_url = format!(
|
||||
@ -223,7 +223,7 @@ pub async fn create_work_item(
|
||||
|
||||
Ok(TicketResult {
|
||||
id: work_item_id.to_string(),
|
||||
ticket_number: format!("#{}", work_item_id),
|
||||
ticket_number: format!("#{work_item_id}"),
|
||||
url: work_item_url,
|
||||
})
|
||||
}
|
||||
@ -246,7 +246,7 @@ pub async fn get_work_item(
|
||||
.bearer_auth(&config.access_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to get work item: {}", e))?;
|
||||
.map_err(|e| format!("Failed to get work item: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -259,7 +259,7 @@ pub async fn get_work_item(
|
||||
let result: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse response: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse response: {e}"))?;
|
||||
|
||||
Ok(WorkItem {
|
||||
id: result["id"]
|
||||
@ -305,7 +305,7 @@ pub async fn update_work_item(
|
||||
.json(&updates)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to update work item: {}", e))?;
|
||||
.map_err(|e| format!("Failed to update work item: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -318,7 +318,7 @@ pub async fn update_work_item(
|
||||
let result: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse response: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse response: {e}"))?;
|
||||
|
||||
let updated_work_item_id = result["id"].as_i64().unwrap_or(work_item_id);
|
||||
let work_item_url = format!(
|
||||
@ -329,7 +329,7 @@ pub async fn update_work_item(
|
||||
|
||||
Ok(TicketResult {
|
||||
id: updated_work_item_id.to_string(),
|
||||
ticket_number: format!("#{}", updated_work_item_id),
|
||||
ticket_number: format!("#{updated_work_item_id}"),
|
||||
url: work_item_url,
|
||||
})
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ pub async fn test_connection(config: &ConfluenceConfig) -> Result<ConnectionResu
|
||||
.bearer_auth(&config.access_token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Connection failed: {}", e))?;
|
||||
.map_err(|e| format!("Connection failed: {e}"))?;
|
||||
|
||||
if resp.status().is_success() {
|
||||
Ok(ConnectionResult {
|
||||
@ -61,7 +61,7 @@ pub async fn list_spaces(config: &ConfluenceConfig) -> Result<Vec<Space>, String
|
||||
.query(&[("limit", "100")])
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to list spaces: {}", e))?;
|
||||
.map_err(|e| format!("Failed to list spaces: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -74,7 +74,7 @@ pub async fn list_spaces(config: &ConfluenceConfig) -> Result<Vec<Space>, String
|
||||
let body: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse response: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse response: {e}"))?;
|
||||
|
||||
let spaces = body["results"]
|
||||
.as_array()
|
||||
@ -114,7 +114,7 @@ pub async fn search_pages(
|
||||
.query(&[("cql", &cql), ("limit", &"50".to_string())])
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Search failed: {}", e))?;
|
||||
.map_err(|e| format!("Search failed: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -127,7 +127,7 @@ pub async fn search_pages(
|
||||
let body: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse response: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse response: {e}"))?;
|
||||
|
||||
let pages = body["results"]
|
||||
.as_array()
|
||||
@ -182,7 +182,7 @@ pub async fn publish_page(
|
||||
.json(&body)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to publish page: {}", e))?;
|
||||
.map_err(|e| format!("Failed to publish page: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -195,7 +195,7 @@ pub async fn publish_page(
|
||||
let result: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse response: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse response: {e}"))?;
|
||||
|
||||
let page_id = result["id"].as_str().unwrap_or("");
|
||||
let page_url = format!(
|
||||
@ -245,7 +245,7 @@ pub async fn update_page(
|
||||
.json(&body)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to update page: {}", e))?;
|
||||
.map_err(|e| format!("Failed to update page: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -258,7 +258,7 @@ pub async fn update_page(
|
||||
let result: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse response: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse response: {e}"))?;
|
||||
|
||||
let updated_page_id = result["id"].as_str().unwrap_or(page_id);
|
||||
let page_url = format!(
|
||||
|
||||
@ -34,7 +34,7 @@ pub async fn test_connection(config: &ServiceNowConfig) -> Result<ConnectionResu
|
||||
.query(&[("sysparm_limit", "1")])
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Connection failed: {}", e))?;
|
||||
.map_err(|e| format!("Connection failed: {e}"))?;
|
||||
|
||||
if resp.status().is_success() {
|
||||
Ok(ConnectionResult {
|
||||
@ -60,7 +60,7 @@ pub async fn search_incidents(
|
||||
config.instance_url.trim_end_matches('/')
|
||||
);
|
||||
|
||||
let sysparm_query = format!("short_descriptionLIKE{}", query);
|
||||
let sysparm_query = format!("short_descriptionLIKE{query}");
|
||||
|
||||
let resp = client
|
||||
.get(&url)
|
||||
@ -71,7 +71,7 @@ pub async fn search_incidents(
|
||||
])
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Search failed: {}", e))?;
|
||||
.map_err(|e| format!("Search failed: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -84,7 +84,7 @@ pub async fn search_incidents(
|
||||
let body: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse response: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse response: {e}"))?;
|
||||
|
||||
let incidents = body["result"]
|
||||
.as_array()
|
||||
@ -134,7 +134,7 @@ pub async fn create_incident(
|
||||
.json(&body)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to create incident: {}", e))?;
|
||||
.map_err(|e| format!("Failed to create incident: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -147,7 +147,7 @@ pub async fn create_incident(
|
||||
let result: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse response: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse response: {e}"))?;
|
||||
|
||||
let incident_number = result["result"]["number"].as_str().unwrap_or("");
|
||||
let sys_id = result["result"]["sys_id"].as_str().unwrap_or("");
|
||||
@ -198,13 +198,13 @@ pub async fn get_incident(
|
||||
.basic_auth(&config.username, Some(&config.password));
|
||||
|
||||
if use_query {
|
||||
request = request.query(&[("sysparm_query", &format!("number={}", incident_id))]);
|
||||
request = request.query(&[("sysparm_query", &format!("number={incident_id}"))]);
|
||||
}
|
||||
|
||||
let resp = request
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to get incident: {}", e))?;
|
||||
.map_err(|e| format!("Failed to get incident: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -217,7 +217,7 @@ pub async fn get_incident(
|
||||
let body: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse response: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse response: {e}"))?;
|
||||
|
||||
let incident_data = if use_query {
|
||||
// Query response has "result" array
|
||||
@ -273,7 +273,7 @@ pub async fn update_incident(
|
||||
.json(&updates)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to update incident: {}", e))?;
|
||||
.map_err(|e| format!("Failed to update incident: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!(
|
||||
@ -286,7 +286,7 @@ pub async fn update_incident(
|
||||
let result: serde_json::Value = resp
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse response: {}", e))?;
|
||||
.map_err(|e| format!("Failed to parse response: {e}"))?;
|
||||
|
||||
let incident_number = result["result"]["number"].as_str().unwrap_or("");
|
||||
let updated_sys_id = result["result"]["sys_id"].as_str().unwrap_or(sys_id);
|
||||
|
||||
@ -32,7 +32,7 @@ pub async fn authenticate_with_webview(
|
||||
format!("{}/_signin", base_url.trim_end_matches('/'))
|
||||
}
|
||||
"servicenow" => format!("{}/login.do", base_url.trim_end_matches('/')),
|
||||
_ => return Err(format!("Unknown service: {}", service)),
|
||||
_ => return Err(format!("Unknown service: {service}")),
|
||||
};
|
||||
|
||||
tracing::info!(
|
||||
@ -46,11 +46,7 @@ pub async fn authenticate_with_webview(
|
||||
let webview = WebviewWindowBuilder::new(
|
||||
&app_handle,
|
||||
&webview_label,
|
||||
WebviewUrl::External(
|
||||
login_url
|
||||
.parse()
|
||||
.map_err(|e| format!("Invalid URL: {}", e))?,
|
||||
),
|
||||
WebviewUrl::External(login_url.parse().map_err(|e| format!("Invalid URL: {e}"))?),
|
||||
)
|
||||
.title(format!("{} Browser (TFTSR)", service))
|
||||
.inner_size(1000.0, 800.0)
|
||||
@ -60,12 +56,12 @@ pub async fn authenticate_with_webview(
|
||||
.focused(true)
|
||||
.visible(true)
|
||||
.build()
|
||||
.map_err(|e| format!("Failed to create webview: {}", e))?;
|
||||
.map_err(|e| format!("Failed to create webview: {e}"))?;
|
||||
|
||||
// Focus the window
|
||||
webview
|
||||
.set_focus()
|
||||
.map_err(|e| tracing::warn!("Failed to focus webview: {}", e))
|
||||
.map_err(|e| tracing::warn!("Failed to focus webview: {e}"))
|
||||
.ok();
|
||||
|
||||
// Wait for user to complete login
|
||||
@ -147,7 +143,7 @@ pub async fn extract_cookies_via_ipc<R: tauri::Runtime>(
|
||||
match serde_json::from_str::<serde_json::Value>(payload_str) {
|
||||
Ok(payload) => {
|
||||
if let Some(error_msg) = payload.get("error").and_then(|e| e.as_str()) {
|
||||
let _ = tx.try_send(Err(format!("JavaScript error: {}", error_msg)));
|
||||
let _ = tx.try_send(Err(format!("JavaScript error: {error_msg}")));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -158,8 +154,8 @@ pub async fn extract_cookies_via_ipc<R: tauri::Runtime>(
|
||||
let _ = tx.try_send(Ok(cookies));
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!("Failed to parse cookies: {}", e);
|
||||
let _ = tx.try_send(Err(format!("Failed to parse cookies: {}", e)));
|
||||
tracing::error!("Failed to parse cookies: {e}");
|
||||
let _ = tx.try_send(Err(format!("Failed to parse cookies: {e}")));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -167,8 +163,8 @@ pub async fn extract_cookies_via_ipc<R: tauri::Runtime>(
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!("Failed to parse event payload: {}", e);
|
||||
let _ = tx.try_send(Err(format!("Failed to parse event payload: {}", e)));
|
||||
tracing::error!("Failed to parse event payload: {e}");
|
||||
let _ = tx.try_send(Err(format!("Failed to parse event payload: {e}")));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -176,7 +172,7 @@ pub async fn extract_cookies_via_ipc<R: tauri::Runtime>(
|
||||
// Inject the script into the webview
|
||||
webview_window
|
||||
.eval(cookie_extraction_script)
|
||||
.map_err(|e| format!("Failed to inject cookie extraction script: {}", e))?;
|
||||
.map_err(|e| format!("Failed to inject cookie extraction script: {e}"))?;
|
||||
|
||||
tracing::info!("Cookie extraction script injected, waiting for response...");
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user