mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 09:34:04 +00:00 
			
		
		
		
	Check the availability of Firebase before accepting new tokens
This commit is contained in:
		@@ -77,7 +77,7 @@ impl ServerConfig {
 | 
			
		||||
            android_direct_download_url: conf().android_direct_download_url.clone(),
 | 
			
		||||
 | 
			
		||||
            notifications: NotificationsConfig {
 | 
			
		||||
                has_firebase: c.firebase_token.is_some(),
 | 
			
		||||
                has_firebase: c.is_firebase_available(),
 | 
			
		||||
                has_independent: conf().independent_push_service.is_some(),
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,10 @@ pub fn configure(r: &mut HttpRequestHandler) -> RequestResult {
 | 
			
		||||
        "disabled" => PushNotificationToken::NONE,
 | 
			
		||||
 | 
			
		||||
        "firebase" => {
 | 
			
		||||
            if !r.api_client().is_firebase_available() {
 | 
			
		||||
                return r.bad_request("Firebase is unavailable!".to_string());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            PushNotificationToken::FIREBASE(r.post_string("firebase_token")?)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,3 +10,9 @@ pub struct APIClient {
 | 
			
		||||
    pub default_expiration_time: u64,
 | 
			
		||||
    pub firebase_token: Option<String>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl APIClient {
 | 
			
		||||
    pub fn is_firebase_available(&self) -> bool {
 | 
			
		||||
        self.firebase_token.is_some()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user