1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-20 16:35:17 +00:00

Can set (update) notifications settings

This commit is contained in:
2021-04-11 13:49:22 +02:00
parent 138142f52d
commit c6306eee7f
5 changed files with 37 additions and 2 deletions

View File

@ -16,6 +16,7 @@ use crate::data::http_request_handler::HttpRequestHandler;
use crate::data::lang_settings::LangSettings;
use crate::data::new_custom_emoji::NewCustomEmoji;
use crate::data::new_data_conservation_policy::NewDataConservationPolicy;
use crate::data::new_notifications_settings::NewNotificationsSettings;
use crate::data::security_settings::{SecurityQuestion, SecuritySettings};
use crate::data::user::{AccountImageVisibility, UserPageStatus};
use crate::helpers::{account_helper, custom_emojies_helper, user_helper};
@ -259,9 +260,20 @@ pub fn set_data_conservation_policy(r: &mut HttpRequestHandler) -> RequestResult
r.success("Successfully updated data conservation policy!")
}
/// Get notification settings
/// Get notifications settings
pub fn get_notifications(r: &mut HttpRequestHandler) -> RequestResult {
let user = user_helper::find_user_by_id(r.user_id_ref()?)?;
r.set_response(NotificationSettingsAPI::new(&user))
}
/// Set (update) notifications settings
pub fn set_notifications(r: &mut HttpRequestHandler) -> RequestResult {
account_helper::set_notifications_settings(NewNotificationsSettings {
user_id: r.user_id()?,
allow_notifications_sound: r.post_bool("allow_notifications_sound")?,
allow_conversations: r.post_bool("allow_conversations")?,
})?;
r.ok()
}