diff --git a/src/app_state.rs b/src/app_state.rs index 0fc34a7..bd7b4e3 100644 --- a/src/app_state.rs +++ b/src/app_state.rs @@ -56,7 +56,7 @@ pub struct AppState { pub schedule: Mutex>, pub database: Mutex, pub vk_id: VkId, - pub fcm_client: Mutex, + pub fcm_client: Option>, // в рантайме не меняется, так что опционален мьютекс, а не данные в нём. } impl AppState { @@ -71,7 +71,13 @@ impl AppState { .unwrap_or_else(|_| panic!("Error connecting to {}", database_url)), ), vk_id: VkId::new(), - fcm_client: Mutex::new(FCMClient::new().await.expect("FCM client must be created")), + fcm_client: if env::var("GOOGLE_APPLICATION_CREDENTIALS").is_ok() { + Some(Mutex::new( + FCMClient::new().await.expect("FCM client must be created"), + )) + } else { + None + }, } } } diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 04781dc..91b9581 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -567,6 +567,8 @@ fn convert_groups_to_teachers( /// # Examples /// /// ``` +/// use schedule_parser_rusted::parser::parse_xls; +/// /// let result = parse_xls(&include_bytes!("../../schedule.xls").to_vec()); /// /// assert!(result.is_ok()); diff --git a/src/routes/fcm/set_token.rs b/src/routes/fcm/set_token.rs index 6ce1faf..d447553 100644 --- a/src/routes/fcm/set_token.rs +++ b/src/routes/fcm/set_token.rs @@ -78,6 +78,8 @@ pub async fn set_token( // Subscribe to default topics. if let Some(e) = app_state .fcm_client + .as_ref() + .unwrap() .async_scope( async |client: &mut FCMClient| -> Result<(), TopicManagementError> { let mut tokens: Vec = Vec::new();