From dd8f26a3f68e4ba4a6ae3d7861d3335ad2463c39 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 29 Oct 2019 14:20:53 -0600 Subject: [PATCH] Add integration manager provisioning setting To be used later by a future implementation --- src/settings/Settings.js | 4 ++++ .../handlers/AccountSettingsHandler.js | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/settings/Settings.js b/src/settings/Settings.js index 7470641359..586ec7d1cf 100644 --- a/src/settings/Settings.js +++ b/src/settings/Settings.js @@ -279,6 +279,10 @@ export const SETTINGS = { supportedLevels: ['account'], default: [], }, + "integration_provisioning": { + supportedLevels: ['account'], + default: true, + }, "analyticsOptIn": { supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG, displayName: _td('Send analytics data'), diff --git a/src/settings/handlers/AccountSettingsHandler.js b/src/settings/handlers/AccountSettingsHandler.js index 1450bed494..435c8f3388 100644 --- a/src/settings/handlers/AccountSettingsHandler.js +++ b/src/settings/handlers/AccountSettingsHandler.js @@ -23,6 +23,8 @@ const BREADCRUMBS_LEGACY_EVENT_TYPE = "im.vector.riot.breadcrumb_rooms"; const BREADCRUMBS_EVENT_TYPE = "im.vector.setting.breadcrumbs"; const BREADCRUMBS_EVENT_TYPES = [BREADCRUMBS_LEGACY_EVENT_TYPE, BREADCRUMBS_EVENT_TYPE]; +const INTEG_PROVISIONING_EVENT_TYPE = "im.vector.setting.integration_provisioning"; + /** * Gets and sets settings at the "account" level for the current user. * This handler does not make use of the roomId parameter. @@ -61,6 +63,9 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa } } else if (BREADCRUMBS_EVENT_TYPES.includes(event.getType())) { this._notifyBreadcrumbsUpdate(event); + } else if (event.getType() === INTEG_PROVISIONING_EVENT_TYPE) { + let val = event.getContent()['enabled']; + this._watchers.notifyUpdate("integration_provisioning", null, SettingLevel.ACCOUNT, val); } } @@ -87,6 +92,12 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa return content && content['recent_rooms'] ? content['recent_rooms'] : []; } + // Special case integration manager provisioning + if (settingName === "integration_provisioning") { + const content = this._getSettings(INTEG_PROVISIONING_EVENT_TYPE); + return content ? content['enabled'] : null; + } + const settings = this._getSettings() || {}; let preferredValue = settings[settingName]; @@ -120,6 +131,13 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa return MatrixClientPeg.get().setAccountData(BREADCRUMBS_EVENT_TYPE, content); } + // Special case integration manager provisioning + if (settingName === "integration_provisioning") { + const content = this._getSettings(INTEG_PROVISIONING_EVENT_TYPE) || {}; + content['enabled'] = newValue; + return MatrixClientPeg.get().setAccountData(INTEG_PROVISIONING_EVENT_TYPE, content); + } + const content = this._getSettings() || {}; content[settingName] = newValue; return MatrixClientPeg.get().setAccountData("im.vector.web.settings", content);