Skip to content

Commit

Permalink
Merge pull request #16 from jutuon/update-dependencies
Browse files Browse the repository at this point in the history
Update dependencies and other improvements
  • Loading branch information
rj76 authored Aug 21, 2024
2 parents 8eb7ced + 1788092 commit ce8b6d0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
7 changes: 2 additions & 5 deletions src/client/oauth.rs
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -34,7 +32,7 @@ impl OauthError {
}

pub(crate) struct OauthClient {
authenticator: Authenticator<HttpsConnector<HttpConnector>>,
authenticator: Authenticator<<DefaultHyperClient as HyperClientBuilder>::Connector>,
project_id: String,
}

Expand All @@ -55,8 +53,7 @@ impl OauthClient {
) -> Result<Self, OauthError> {
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 {
Expand Down
4 changes: 3 additions & 1 deletion src/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ impl AsRef<Message> for Message {
}
}

/// Wrap the message in a "message" field
#[allow(clippy::bool_comparison)]
fn is_validate_only_default(b: &bool) -> bool {
*b == false
}

/// Data for FCM send API request body JSON
/// <https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send?authuser=0#request-body>
#[derive(Serialize)]
pub(crate) struct MessageWrapper<'a> {
#[serde(skip_serializing_if = "is_validate_only_default")]
Expand Down

0 comments on commit ce8b6d0

Please sign in to comment.