diff --git a/services/tunnelbroker/src/notifs/fcm/error.rs b/services/tunnelbroker/src/notifs/fcm/error.rs --- a/services/tunnelbroker/src/notifs/fcm/error.rs +++ b/services/tunnelbroker/src/notifs/fcm/error.rs @@ -1,3 +1,4 @@ +use crate::notifs::fcm::response::FCMError; use derive_more::{Display, Error, From}; #[derive(Debug, From, Display, Error)] @@ -7,6 +8,7 @@ InvalidHeaderValue(reqwest::header::InvalidHeaderValue), SerdeJson(serde_json::Error), FCMTokenNotInitialized, + FCMError(FCMError), } impl From for Error { diff --git a/services/tunnelbroker/src/notifs/fcm/mod.rs b/services/tunnelbroker/src/notifs/fcm/mod.rs --- a/services/tunnelbroker/src/notifs/fcm/mod.rs +++ b/services/tunnelbroker/src/notifs/fcm/mod.rs @@ -5,6 +5,7 @@ pub mod config; mod error; mod firebase_message; +mod response; mod token; #[derive(Clone)] diff --git a/services/tunnelbroker/src/notifs/fcm/response.rs b/services/tunnelbroker/src/notifs/fcm/response.rs new file mode 100644 --- /dev/null +++ b/services/tunnelbroker/src/notifs/fcm/response.rs @@ -0,0 +1,44 @@ +use derive_more::{Display, Error}; + +#[derive(PartialEq, Debug, Clone, Display, Error)] +pub struct InvalidArgumentError { + pub details: String, +} +#[derive(PartialEq, Debug, Display, Error)] +pub enum FCMError { + /// No more information is available about this error. + UnspecifiedError, + + /// HTTP error code = 400. + /// Request parameters were invalid. + /// Potential causes include invalid registration, invalid package name, + /// message too big, invalid data key, invalid TTL, or other invalid + /// parameters. + InvalidArgument(InvalidArgumentError), + + /// HTTP error code = 404. + /// App instance was unregistered from FCM. This usually means that + /// the token used is no longer valid and a new one must be used. + Unregistered, + + /// HTTP error code = 403. + /// The authenticated sender ID is different from the sender ID for + /// the registration token. + SenderIdMismatch, + + /// HTTP error code = 429. + /// Sending limit exceeded for the message target. + QuotaExceeded, + + /// HTTP error code = 503. + /// The server is overloaded. + Unavailable, + + /// HTTP error code = 500. + /// An unknown internal error occurred. + Internal, + + /// HTTP error code = 401. + /// APNs certificate or web push auth key was invalid or missing. + ThirdPartyAuthError, +}