From 2b3900bf16a628f005aa19f641dea11fed14c530 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 5 May 2024 13:48:03 +0100 Subject: [PATCH 1/2] chore: bump a2 --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- src/handlers/register_client.rs | 6 +++--- src/handlers/update_apns.rs | 5 +++-- src/providers/apns.rs | 6 +++--- src/providers/fcm.rs | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b902ac83..8c4839c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,8 +5,7 @@ version = 3 [[package]] name = "a2" version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9113bcfcb2f288f0619d47d84f712ddad87b4d0a79245b2d61ffe13960fb8ac8" +source = "git+https://github.com/threema-donat/a2.git?branch=add_timeout#b938e2dce24a88b66f3380fab53df2a0aace6452" dependencies = [ "base64 0.21.4", "erased-serde", @@ -16,11 +15,13 @@ dependencies = [ "hyper-rustls 0.26.0", "hyper-util", "openssl", + "parking_lot 0.12.1", "rustls 0.22.4", "rustls-pemfile 2.1.1", "serde", "serde_json", "thiserror", + "tokio", "tracing", ] diff --git a/Cargo.toml b/Cargo.toml index 9603ca1a..bda67fa4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ tracing-opentelemetry = "0.18" atty = "0.2" # Push -a2 = { version = "0.9.0", features = ["tracing", "openssl"] } +a2 = { git = "https://github.com/threema-donat/a2.git", branch = "add_timeout", features = ["tracing", "openssl"] } fcm = "0.9" # Signature validation diff --git a/src/handlers/register_client.rs b/src/handlers/register_client.rs index 67ac743d..9b826e91 100644 --- a/src/handlers/register_client.rs +++ b/src/handlers/register_client.rs @@ -78,9 +78,9 @@ pub async fn handler( return Err(EmptyField("token".to_string())); } - let mut client_id = body.client_id.to_string(); - - client_id = client_id + let client_id = body + .client_id + .as_ref() .trim_start_matches(DECENTRALIZED_IDENTIFIER_PREFIX) .to_owned(); diff --git a/src/handlers/update_apns.rs b/src/handlers/update_apns.rs index d01a3ae4..d4951d37 100644 --- a/src/handlers/update_apns.rs +++ b/src/handlers/update_apns.rs @@ -6,6 +6,7 @@ use { state::AppState, stores::tenant::{TenantApnsUpdateAuth, TenantApnsUpdateParams}, }, + a2::ClientConfig, axum::{ extract::{Multipart, Path, State}, http::HeaderMap, @@ -220,7 +221,7 @@ pub async fn handler( match a2::Client::certificate( &mut std::io::Cursor::new(decoded), &apns_certificate_password, - a2::Endpoint::Sandbox, + ClientConfig::new(a2::Endpoint::Sandbox), ) { Ok(_) => Ok(()), Err(e) => { @@ -240,7 +241,7 @@ pub async fn handler( &mut std::io::Cursor::new(decoded), apns_key_id, apns_team_id, - a2::Endpoint::Sandbox, + ClientConfig::new(a2::Endpoint::Sandbox), ) { Ok(_) => Ok(()), Err(e) => { diff --git a/src/providers/apns.rs b/src/providers/apns.rs index e0421682..9dadffbd 100644 --- a/src/providers/apns.rs +++ b/src/providers/apns.rs @@ -1,7 +1,7 @@ use { super::{LegacyPushMessage, PushMessage, RawPushMessage}, crate::{blob::DecryptedPayloadBlob, error::Error, providers::PushProvider}, - a2::{ErrorReason, NotificationBuilder, NotificationOptions}, + a2::{ClientConfig, ErrorReason, NotificationBuilder, NotificationOptions}, async_trait::async_trait, std::io::Read, tracing::{debug, info, instrument, warn}, @@ -24,7 +24,7 @@ impl ApnsProvider { R: Read, { Ok(ApnsProvider { - client: a2::Client::certificate(cert, password.as_str(), endpoint)?, + client: a2::Client::certificate(cert, password.as_str(), ClientConfig::new(endpoint))?, topic, }) } @@ -40,7 +40,7 @@ impl ApnsProvider { R: Read, { Ok(ApnsProvider { - client: a2::Client::token(pkcs8_pem, key_id, team_id, endpoint)?, + client: a2::Client::token(pkcs8_pem, key_id, team_id, ClientConfig::new(endpoint))?, topic, }) } diff --git a/src/providers/fcm.rs b/src/providers/fcm.rs index 6352002c..f5e89d8e 100644 --- a/src/providers/fcm.rs +++ b/src/providers/fcm.rs @@ -105,7 +105,7 @@ impl Clone for FcmProvider { } fn clone_from(&mut self, source: &Self) { - self.api_key = source.api_key.clone(); + self.api_key.clone_from(&source.api_key); self.client = fcm::Client::new(); } } From d455685fd6803a386ca969a0803e0042f6477a33 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 5 May 2024 13:54:16 +0100 Subject: [PATCH 2/2] chore: use tagged version --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c4839c4..b45f7e17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,8 +4,9 @@ version = 3 [[package]] name = "a2" -version = "0.9.0" -source = "git+https://github.com/threema-donat/a2.git?branch=add_timeout#b938e2dce24a88b66f3380fab53df2a0aace6452" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f279fc8b1f1a64138f0f4b9cda9be488ae35bc2f8556c7ffe60730f1c07d005a" dependencies = [ "base64 0.21.4", "erased-serde", diff --git a/Cargo.toml b/Cargo.toml index bda67fa4..76ac96cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ tracing-opentelemetry = "0.18" atty = "0.2" # Push -a2 = { git = "https://github.com/threema-donat/a2.git", branch = "add_timeout", features = ["tracing", "openssl"] } +a2 = { version = "0.10.0", features = ["tracing", "openssl"] } fcm = "0.9" # Signature validation