diff --git a/src/api/mod.rs b/src/api/mod.rs index 2afeb98..7c616ee 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,19 +1,19 @@ use serde::{de::DeserializeOwned, Serialize}; -use crate::settings::get_current_account; +use crate::{config, settings::get_current_account}; pub mod auth; pub mod comment; pub mod communities; pub mod community; +pub mod image; +pub mod instances; pub mod moderation; pub mod post; pub mod posts; pub mod private_message; pub mod search; pub mod site; -pub mod image; -pub mod instances; pub mod user; static API_VERSION: &str = "v3"; @@ -21,7 +21,13 @@ static API_VERSION: &str = "v3"; use relm4::once_cell::sync::Lazy; use reqwest::blocking::Client; -pub static CLIENT: Lazy = Lazy::new(|| Client::new()); +pub static CLIENT: Lazy = Lazy::new(|| { + let user_agent = format!("{}/{}", config::NAME, config::VERSION); + Client::builder() + .user_agent(user_agent) + .build() + .expect("Failed to create reqwest http client!") +}); fn get_api_url() -> String { format!("{}/api/{}", get_current_account().instance_url, API_VERSION).to_string()