diff --git a/Cargo.lock b/Cargo.lock index b634c608..cd702ac3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1529,7 +1529,7 @@ dependencies = [ [[package]] name = "fcm" version = "0.10.0" -source = "git+https://github.com/WalletConnect/fcm-rust.git?branch=feat/key-not-from-file#da38296727bd223293d6a5f558f952f76d8134e1" +source = "git+https://github.com/WalletConnect/fcm-rust.git?branch=feat/key-not-from-file#521683cec85f451314396098e440bb4782bd1f4f" dependencies = [ "chrono", "erased-serde 0.4.4", diff --git a/src/providers/apns.rs b/src/providers/apns.rs index 683cf295..a3060030 100644 --- a/src/providers/apns.rs +++ b/src/providers/apns.rs @@ -143,6 +143,7 @@ impl PushProvider for ApnsProvider { ErrorReason::Unregistered => Err(Error::BadDeviceToken( "The device token is inactive for the specified topic".to_string(), )), + ErrorReason::TopicDisallowed => Err(Error::BadApnsCredentials), reason => Err(Error::ApnsResponse(reason)), }, }, diff --git a/src/providers/fcm_v1.rs b/src/providers/fcm_v1.rs index 273bfb7f..7324d0dc 100644 --- a/src/providers/fcm_v1.rs +++ b/src/providers/fcm_v1.rs @@ -4,7 +4,7 @@ use { async_trait::async_trait, fcm_v1::{ gauth::serv_account::ServiceAccountKey, AndroidConfig, AndroidMessagePriority, ApnsConfig, - Client, ClientBuildError, ErrorReason, Message, Notification, Response, Target, + Client, ClientBuildError, Message, Notification, SendError, Target, }, serde::Serialize, serde_json::json, @@ -118,32 +118,10 @@ impl PushProvider for FcmV1Provider { } }; - #[allow(clippy::match_single_binding)] - match result { - Ok(val) => { - let Response { error, .. } = val; - if let Some(error) = error { - match error { - ErrorReason::MissingRegistration => Err(Error::BadDeviceToken( - "Missing registration for token".into(), - )), - ErrorReason::InvalidRegistration => { - Err(Error::BadDeviceToken("Invalid token registration".into())) - } - ErrorReason::NotRegistered => { - Err(Error::BadDeviceToken("Token is not registered".into())) - } - ErrorReason::InvalidApnsCredential => Err(Error::BadApnsCredentials), - e => Err(Error::FcmV1Response(e)), - } - } else { - Ok(()) - } - } - Err(e) => match e { - // SendError::Unauthorized => Err(Error::BadFcmV1Credentials), - e => Err(Error::FcmV1(e)), - }, - } + result.map(|_| ()).map_err(|e| match e { + SendError::Unregistered => Error::BadDeviceToken("Token was unregistered".into()), + SendError::Forbidden => Error::BadFcmV1Credentials, + e => Error::FcmV1(e), + }) } }