From d5a5106416c1e0953f07d14ee4915213b069e1f3 Mon Sep 17 00:00:00 2001 From: Juuso Tuononen Date: Sat, 17 Aug 2024 11:48:58 +0300 Subject: [PATCH 1/3] Update reqwest and yup-oauth2 Changes naming of TLS related Cargo features to match with reqwest. --- Cargo.toml | 10 +++++----- src/client/oauth.rs | 7 ++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 670608ac3..cd6d137b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,19 +18,19 @@ edition = "2018" [features] default = ["native-tls"] -native-tls = ["reqwest/native-tls"] -rustls = ["reqwest/rustls-tls"] -vendored-tls = ["reqwest/native-tls-vendored"] +native-tls = ["reqwest/native-tls", "yup-oauth2/hyper-tls"] +native-tls-vendored = ["reqwest/native-tls-vendored", "yup-oauth2/hyper-tls"] +rustls-tls = ["reqwest/rustls-tls", "yup-oauth2/hyper-rustls"] [dependencies] serde = { version = "1", features = ["derive"] } serde_json = { version = "1", features = ["preserve_order"] } tokio = { version = "1", features = ["fs"] } -reqwest = { version = "0.11", features = ["json"], default-features = false } +reqwest = { version = "0.12", features = ["json", "charset", "http2", "macos-system-configuration"], default-features = false } chrono = "0.4" thiserror = "1" dotenvy = "0.15" -yup-oauth2 = "9" +yup-oauth2 = { version = "11", features = ["service-account", "ring"], default-features = false } [dev-dependencies] tokio = { version = "1.0", features = ["rt-multi-thread", "macros"] } diff --git a/src/client/oauth.rs b/src/client/oauth.rs index 9d3388068..ea137c22f 100644 --- a/src/client/oauth.rs +++ b/src/client/oauth.rs @@ -1,8 +1,6 @@ use std::path::PathBuf; use yup_oauth2::authenticator::{Authenticator, DefaultHyperClient, HyperClientBuilder}; -use yup_oauth2::hyper::client::HttpConnector; -use yup_oauth2::hyper_rustls::HttpsConnector; use yup_oauth2::ServiceAccountAuthenticator; const FIREBASE_OAUTH_SCOPE: &str = "https://www.googleapis.com/auth/firebase.messaging"; @@ -34,7 +32,7 @@ impl OauthError { } pub(crate) struct OauthClient { - authenticator: Authenticator>, + authenticator: Authenticator<::Connector>, project_id: String, } @@ -55,8 +53,7 @@ impl OauthClient { ) -> Result { let key = yup_oauth2::parse_service_account_key(service_account_key_json_string) .map_err(OauthError::ServiceAccountKeyReadingFailed)?; - let oauth_client = DefaultHyperClient.build_hyper_client().map_err(OauthError::Oauth)?; - let builder = ServiceAccountAuthenticator::with_client(key.clone(), oauth_client); + let builder = ServiceAccountAuthenticator::builder(key.clone()); let builder = if let Some(path) = token_cache_json_path { builder.persist_tokens_to_disk(path) } else { From 1b2991380ddaf288b3dc9c3ab9514a48771274c0 Mon Sep 17 00:00:00 2001 From: Juuso Tuononen Date: Sat, 17 Aug 2024 13:40:23 +0300 Subject: [PATCH 2/3] Fix MessageWrapper doc comment --- src/message/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/message/mod.rs b/src/message/mod.rs index dba27d2b2..c61ec6ae5 100644 --- a/src/message/mod.rs +++ b/src/message/mod.rs @@ -81,11 +81,12 @@ impl AsRef for Message { } } -/// Wrap the message in a "message" field fn is_validate_only_default(b: &bool) -> bool { *b == false } +/// Data for FCM send API request body JSON +/// #[derive(Serialize)] pub(crate) struct MessageWrapper<'a> { #[serde(skip_serializing_if = "is_validate_only_default")] From 1788092b8db6aeb50945ff4e279899d9b9336b2e Mon Sep 17 00:00:00 2001 From: Juuso Tuononen Date: Sat, 17 Aug 2024 13:41:07 +0300 Subject: [PATCH 3/3] Ignore clippy warning --- src/message/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/message/mod.rs b/src/message/mod.rs index c61ec6ae5..3615410e2 100644 --- a/src/message/mod.rs +++ b/src/message/mod.rs @@ -81,6 +81,7 @@ impl AsRef for Message { } } +#[allow(clippy::bool_comparison)] fn is_validate_only_default(b: &bool) -> bool { *b == false }