mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-07-15 11:48:05 +00:00
Register indpendent service token
This commit is contained in:
src
api_data
controllers
data
helpers
@ -4,9 +4,10 @@
|
||||
|
||||
use crate::api_data::push_notifications_status_api::PushNotificationsStatusAPI;
|
||||
use crate::data::base_request_handler::BaseRequestHandler;
|
||||
use crate::data::config::conf;
|
||||
use crate::data::http_request_handler::HttpRequestHandler;
|
||||
use crate::data::user_token::PushNotificationToken;
|
||||
use crate::helpers::account_helper;
|
||||
use crate::helpers::{account_helper, independent_push_notification_service_helper};
|
||||
use crate::routes::RequestResult;
|
||||
|
||||
/// Get current push notifications status for a connection
|
||||
@ -20,8 +21,6 @@ pub fn get_status(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
pub fn configure(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let status = r.post_string("status")?;
|
||||
|
||||
// TODO : check availability of each option
|
||||
|
||||
let status = match status.as_str() {
|
||||
"disabled" => PushNotificationToken::NONE,
|
||||
|
||||
@ -34,7 +33,13 @@ pub fn configure(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
}
|
||||
|
||||
"independent" => {
|
||||
unimplemented!();
|
||||
if !conf().is_independent_push_notifications_service_enabled() {
|
||||
return r.bad_request("Independent service is unavailable!".to_string());
|
||||
}
|
||||
|
||||
let token = independent_push_notification_service_helper::create_token()?;
|
||||
|
||||
PushNotificationToken::INDEPENDENT(token)
|
||||
}
|
||||
|
||||
_ => {
|
||||
|
Reference in New Issue
Block a user