From 0a45483875ff241638b02d5b41794e742581b4cd Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Thu, 10 Oct 2024 12:31:03 +0200 Subject: [PATCH] feat(config): create standard service request for user config Signed-off-by: DorraJaouad --- .../SettingsDialog/SettingsDialog.vue | 6 +++--- src/services/settingsService.js | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/components/SettingsDialog/SettingsDialog.vue b/src/components/SettingsDialog/SettingsDialog.vue index 7aed84d658d..2d423d03cd9 100644 --- a/src/components/SettingsDialog/SettingsDialog.vue +++ b/src/components/SettingsDialog/SettingsDialog.vue @@ -204,6 +204,7 @@ import { PRIVACY } from '../../constants.js' import BrowserStorage from '../../services/BrowserStorage.js' import { getTalkConfig } from '../../services/CapabilitiesManager.ts' import { useCustomSettings } from '../../services/SettingsAPI.ts' +import { setUserConfig } from '../../services/settingsService.js' import { useSettingsStore } from '../../stores/settings.js' import { useSoundsStore } from '../../stores/sounds.js' @@ -297,12 +298,11 @@ export default { }, }, - created() { + async created() { const blurred = BrowserStorage.getItem('background-blurred') if (blurred === 'false' && isBackgroundBlurred === '') { console.debug('Blur was disabled intentionally, propagating last choice to server') - axios.post(generateOcsUrl('apps/provisioning_api/api/v1/config/users/theming/force_enable_blur_filter'), - { configValue: 'no' }) + await setUserConfig('theming', 'force_enable_blur_filter', 'no') } BrowserStorage.removeItem('background-blurred') }, diff --git a/src/services/settingsService.js b/src/services/settingsService.js index 4ba063457ec..684e8a8babe 100644 --- a/src/services/settingsService.js +++ b/src/services/settingsService.js @@ -75,8 +75,20 @@ const setPlaySounds = async function(hasUserAccount, value) { } const setStartWithoutMedia = async function(value) { - await axios.post(generateOcsUrl('apps/provisioning_api/api/v1/config/users/spreed/calls_start_without_media'), - { configValue: value ? 'yes' : 'no' }) + await setUserConfig('spreed', 'calls_start_without_media', value ? 'yes' : 'no') +} + +/** + * Set user config using provisioning API + * + * @param {string} appId - app id + * @param {string} configKey - key of the config to set + * @param {string} configValue - value to set + */ +const setUserConfig = async function(appId, configKey, configValue) { + await axios.post(generateOcsUrl('apps/provisioning_api/api/v1/config/users/{appId}/{configKey}', { appId, configKey }), { + configValue, + }) } export { @@ -86,4 +98,5 @@ export { setSIPSettings, setPlaySounds, setStartWithoutMedia, + setUserConfig, }