UNPKG

mattermost-redux

Version:

Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client

848 lines (847 loc) 29.4 kB
"use strict"; // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. Object.defineProperty(exports, "__esModule", { value: true }); exports.getLogs = getLogs; exports.getPlainLogs = getPlainLogs; exports.getAudits = getAudits; exports.getConfig = getConfig; exports.patchConfig = patchConfig; exports.reloadConfig = reloadConfig; exports.getEnvironmentConfig = getEnvironmentConfig; exports.testEmail = testEmail; exports.testSiteURL = testSiteURL; exports.testS3Connection = testS3Connection; exports.invalidateCaches = invalidateCaches; exports.recycleDatabase = recycleDatabase; exports.createComplianceReport = createComplianceReport; exports.getComplianceReport = getComplianceReport; exports.getComplianceReports = getComplianceReports; exports.uploadBrandImage = uploadBrandImage; exports.deleteBrandImage = deleteBrandImage; exports.getClusterStatus = getClusterStatus; exports.testLdap = testLdap; exports.testLdapConnection = testLdapConnection; exports.testLdapFilters = testLdapFilters; exports.testLdapAttributes = testLdapAttributes; exports.testLdapGroupAttributes = testLdapGroupAttributes; exports.syncLdap = syncLdap; exports.getLdapGroups = getLdapGroups; exports.linkLdapGroup = linkLdapGroup; exports.unlinkLdapGroup = unlinkLdapGroup; exports.getSamlCertificateStatus = getSamlCertificateStatus; exports.uploadPublicSamlCertificate = uploadPublicSamlCertificate; exports.uploadPrivateSamlCertificate = uploadPrivateSamlCertificate; exports.uploadPublicLdapCertificate = uploadPublicLdapCertificate; exports.uploadPrivateLdapCertificate = uploadPrivateLdapCertificate; exports.uploadIdpSamlCertificate = uploadIdpSamlCertificate; exports.uploadAuditCertificate = uploadAuditCertificate; exports.removeAuditCertificate = removeAuditCertificate; exports.removePublicSamlCertificate = removePublicSamlCertificate; exports.removePrivateSamlCertificate = removePrivateSamlCertificate; exports.removePublicLdapCertificate = removePublicLdapCertificate; exports.removePrivateLdapCertificate = removePrivateLdapCertificate; exports.removeIdpSamlCertificate = removeIdpSamlCertificate; exports.testElasticsearch = testElasticsearch; exports.purgeElasticsearchIndexes = purgeElasticsearchIndexes; exports.uploadLicense = uploadLicense; exports.removeLicense = removeLicense; exports.getPrevTrialLicense = getPrevTrialLicense; exports.getAnalytics = getAnalytics; exports.getStandardAnalytics = getStandardAnalytics; exports.getAdvancedAnalytics = getAdvancedAnalytics; exports.getPostsPerDayAnalytics = getPostsPerDayAnalytics; exports.getBotPostsPerDayAnalytics = getBotPostsPerDayAnalytics; exports.getUsersPerDayAnalytics = getUsersPerDayAnalytics; exports.uploadPlugin = uploadPlugin; exports.installPluginFromUrl = installPluginFromUrl; exports.getPlugins = getPlugins; exports.getPluginStatuses = getPluginStatuses; exports.removePlugin = removePlugin; exports.enablePlugin = enablePlugin; exports.disablePlugin = disablePlugin; exports.getSamlMetadataFromIdp = getSamlMetadataFromIdp; exports.setSamlIdpCertificateFromMetadata = setSamlIdpCertificateFromMetadata; exports.getDataRetentionCustomPolicies = getDataRetentionCustomPolicies; exports.getDataRetentionCustomPolicy = getDataRetentionCustomPolicy; exports.deleteDataRetentionCustomPolicy = deleteDataRetentionCustomPolicy; exports.getDataRetentionCustomPolicyTeams = getDataRetentionCustomPolicyTeams; exports.getDataRetentionCustomPolicyChannels = getDataRetentionCustomPolicyChannels; exports.searchDataRetentionCustomPolicyTeams = searchDataRetentionCustomPolicyTeams; exports.searchDataRetentionCustomPolicyChannels = searchDataRetentionCustomPolicyChannels; exports.createDataRetentionCustomPolicy = createDataRetentionCustomPolicy; exports.updateDataRetentionCustomPolicy = updateDataRetentionCustomPolicy; exports.addDataRetentionCustomPolicyTeams = addDataRetentionCustomPolicyTeams; exports.removeDataRetentionCustomPolicyTeams = removeDataRetentionCustomPolicyTeams; exports.addDataRetentionCustomPolicyChannels = addDataRetentionCustomPolicyChannels; exports.removeDataRetentionCustomPolicyChannels = removeDataRetentionCustomPolicyChannels; exports.completeSetup = completeSetup; exports.getAppliedSchemaMigrations = getAppliedSchemaMigrations; exports.getIPFilters = getIPFilters; exports.getCurrentIP = getCurrentIP; exports.applyIPFilters = applyIPFilters; const redux_batched_actions_1 = require("redux-batched-actions"); const action_types_1 = require("mattermost-redux/action_types"); const limits_1 = require("mattermost-redux/actions/limits"); const client_1 = require("mattermost-redux/client"); const errors_1 = require("./errors"); const helpers_1 = require("./helpers"); const constants_1 = require("../constants"); function getLogs({ serverNames = [], logLevels = [], dateFrom, dateTo }) { const logFilter = { server_names: serverNames, log_levels: logLevels, date_from: dateFrom, date_to: dateTo, }; return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getLogs, onSuccess: [action_types_1.AdminTypes.RECEIVED_LOGS], params: [ logFilter, ], }); } function getPlainLogs(page = 0, perPage = constants_1.General.LOGS_PAGE_SIZE_DEFAULT) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getPlainLogs, onSuccess: [action_types_1.AdminTypes.RECEIVED_PLAIN_LOGS], params: [ page, perPage, ], }); } function getAudits(page = 0, perPage = constants_1.General.PAGE_SIZE_DEFAULT) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getAudits, onSuccess: [action_types_1.AdminTypes.RECEIVED_AUDITS], params: [ page, perPage, ], }); } function getConfig() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getConfig, onSuccess: [action_types_1.AdminTypes.RECEIVED_CONFIG], }); } function patchConfig(config) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.patchConfig, onSuccess: [action_types_1.AdminTypes.RECEIVED_CONFIG], params: [ config, ], }); } function reloadConfig() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.reloadConfig, }); } function getEnvironmentConfig() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getEnvironmentConfig, onSuccess: [action_types_1.AdminTypes.RECEIVED_ENVIRONMENT_CONFIG], }); } function testEmail(config) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.testEmail, params: [ config, ], }); } function testSiteURL(siteURL) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.testSiteURL, params: [ siteURL, ], }); } function testS3Connection(config) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.testS3Connection, params: [ config, ], }); } function invalidateCaches() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.invalidateCaches, }); } function recycleDatabase() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.recycleDatabase, }); } function createComplianceReport(job) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.createComplianceReport, onRequest: action_types_1.AdminTypes.CREATE_COMPLIANCE_REQUEST, onSuccess: [action_types_1.AdminTypes.RECEIVED_COMPLIANCE_REPORT, action_types_1.AdminTypes.CREATE_COMPLIANCE_SUCCESS], onFailure: action_types_1.AdminTypes.CREATE_COMPLIANCE_FAILURE, params: [ job, ], }); } function getComplianceReport(reportId) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getComplianceReport, onSuccess: [action_types_1.AdminTypes.RECEIVED_COMPLIANCE_REPORT], params: [ reportId, ], }); } function getComplianceReports(page = 0, perPage = constants_1.General.PAGE_SIZE_DEFAULT) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getComplianceReports, onSuccess: [action_types_1.AdminTypes.RECEIVED_COMPLIANCE_REPORTS], params: [ page, perPage, ], }); } function uploadBrandImage(imageData) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.uploadBrandImage, params: [ imageData, ], }); } function deleteBrandImage() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.deleteBrandImage, }); } function getClusterStatus() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getClusterStatus, onSuccess: [action_types_1.AdminTypes.RECEIVED_CLUSTER_STATUS], }); } function testLdap() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.testLdap, }); } function testLdapConnection(settings) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.testLdapConnection, params: [ settings, ], }); } function testLdapFilters(settings) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.testLdapFilters, params: [ settings, ], }); } function testLdapAttributes(settings) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.testLdapAttributes, params: [ settings, ], }); } function testLdapGroupAttributes(settings) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.testLdapGroupAttributes, params: [ settings, ], }); } function syncLdap() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.syncLdap, }); } function getLdapGroups(page = 0, perPage = constants_1.General.PAGE_SIZE_MAXIMUM, opts = { q: '' }) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getLdapGroups, onSuccess: [action_types_1.AdminTypes.RECEIVED_LDAP_GROUPS], params: [ page, perPage, opts, ], }); } function linkLdapGroup(key) { return async (dispatch, getState) => { let data; try { data = await client_1.Client4.linkLdapGroup(key); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch({ type: action_types_1.AdminTypes.LINK_LDAP_GROUP_FAILURE, error, data: key }); dispatch((0, errors_1.logError)(error)); return { error }; } dispatch({ type: action_types_1.AdminTypes.LINKED_LDAP_GROUP, data: { primary_key: key, name: data.display_name, mattermost_group_id: data.id, has_syncables: false, }, }); return { data: true }; }; } function unlinkLdapGroup(key) { return async (dispatch, getState) => { try { await client_1.Client4.unlinkLdapGroup(key); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch({ type: action_types_1.AdminTypes.UNLINK_LDAP_GROUP_FAILURE, error, data: key }); dispatch((0, errors_1.logError)(error)); return { error }; } dispatch({ type: action_types_1.AdminTypes.UNLINKED_LDAP_GROUP, data: key, }); return { data: true }; }; } function getSamlCertificateStatus() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getSamlCertificateStatus, onSuccess: [action_types_1.AdminTypes.RECEIVED_SAML_CERT_STATUS], }); } function uploadPublicSamlCertificate(fileData) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.uploadPublicSamlCertificate, params: [ fileData, ], }); } function uploadPrivateSamlCertificate(fileData) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.uploadPrivateSamlCertificate, params: [ fileData, ], }); } function uploadPublicLdapCertificate(fileData) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.uploadPublicLdapCertificate, params: [ fileData, ], }); } function uploadPrivateLdapCertificate(fileData) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.uploadPrivateLdapCertificate, params: [ fileData, ], }); } function uploadIdpSamlCertificate(fileData) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.uploadIdpSamlCertificate, params: [ fileData, ], }); } function uploadAuditCertificate(fileData) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.uploadAuditLogCertificate, params: [ fileData, ], }); } function removeAuditCertificate() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.removeAuditLogCertificate, }); } function removePublicSamlCertificate() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.deletePublicSamlCertificate, }); } function removePrivateSamlCertificate() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.deletePrivateSamlCertificate, }); } function removePublicLdapCertificate() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.deletePublicLdapCertificate, }); } function removePrivateLdapCertificate() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.deletePrivateLdapCertificate, }); } function removeIdpSamlCertificate() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.deleteIdpSamlCertificate, }); } function testElasticsearch(config) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.testElasticsearch, params: [ config, ], }); } function purgeElasticsearchIndexes(indexes) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.purgeElasticsearchIndexes, params: [ indexes, ], }); } function uploadLicense(fileData) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.uploadLicense, params: [ fileData, ], }); } function removeLicense() { return async (dispatch, getState) => { try { await client_1.Client4.removeLicense(); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch((0, errors_1.logError)(error)); return { error: error }; } await dispatch((0, limits_1.getServerLimits)()); return { data: true }; }; } function getPrevTrialLicense() { return async (dispatch, getState) => { let data; try { data = await client_1.Client4.getPrevTrialLicense(); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); return { error }; } dispatch({ type: action_types_1.AdminTypes.PREV_TRIAL_LICENSE_SUCCESS, data }); return { data }; }; } function getAnalytics(name, teamId = '') { return async (dispatch, getState) => { let data; try { data = await client_1.Client4.getAnalytics(name, teamId); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch((0, errors_1.logError)(error)); return { error }; } if (teamId === '') { dispatch({ type: action_types_1.AdminTypes.RECEIVED_SYSTEM_ANALYTICS, data, name }); } else { dispatch({ type: action_types_1.AdminTypes.RECEIVED_TEAM_ANALYTICS, data, name, teamId }); } return { data }; }; } function getStandardAnalytics(teamId = '') { return getAnalytics('standard', teamId); } function getAdvancedAnalytics(teamId = '') { return getAnalytics('extra_counts', teamId); } function getPostsPerDayAnalytics(teamId = '') { return getAnalytics('post_counts_day', teamId); } function getBotPostsPerDayAnalytics(teamId = '') { return getAnalytics('bot_post_counts_day', teamId); } function getUsersPerDayAnalytics(teamId = '') { return getAnalytics('user_counts_with_posts_day', teamId); } function uploadPlugin(fileData, force = false) { return async (dispatch, getState) => { let data; try { data = await client_1.Client4.uploadPlugin(fileData, force); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch((0, errors_1.logError)(error)); return { error }; } return { data }; }; } function installPluginFromUrl(url, force = false) { return async (dispatch, getState) => { let data; try { data = await client_1.Client4.installPluginFromUrl(url, force); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch((0, errors_1.logError)(error)); return { error }; } return { data }; }; } function getPlugins() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getPlugins, onSuccess: [action_types_1.AdminTypes.RECEIVED_PLUGINS], }); } function getPluginStatuses() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getPluginStatuses, onSuccess: [action_types_1.AdminTypes.RECEIVED_PLUGIN_STATUSES], }); } function removePlugin(pluginId) { return async (dispatch, getState) => { try { await client_1.Client4.removePlugin(pluginId); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch((0, errors_1.logError)(error)); return { error }; } dispatch((0, redux_batched_actions_1.batchActions)([ { type: action_types_1.AdminTypes.REMOVED_PLUGIN, data: pluginId }, { type: action_types_1.AdminTypes.DISABLED_PLUGIN, data: pluginId }, ])); return { data: true }; }; } function enablePlugin(pluginId) { return async (dispatch, getState) => { try { await client_1.Client4.enablePlugin(pluginId); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch((0, errors_1.logError)(error)); return { error }; } dispatch({ type: action_types_1.AdminTypes.ENABLED_PLUGIN, data: pluginId }); return { data: true }; }; } function disablePlugin(pluginId) { return async (dispatch, getState) => { dispatch({ type: action_types_1.AdminTypes.DISABLE_PLUGIN_REQUEST, data: pluginId }); try { await client_1.Client4.disablePlugin(pluginId); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch((0, errors_1.logError)(error)); return { error }; } dispatch({ type: action_types_1.AdminTypes.DISABLED_PLUGIN, data: pluginId }); return { data: true }; }; } function getSamlMetadataFromIdp(samlMetadataURL) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getSamlMetadataFromIdp, onSuccess: action_types_1.AdminTypes.RECEIVED_SAML_METADATA_RESPONSE, params: [ samlMetadataURL, ], }); } function setSamlIdpCertificateFromMetadata(certData) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.setSamlIdpCertificateFromMetadata, params: [ certData, ], }); } function getDataRetentionCustomPolicies(page = 0, perPage = 10) { return async (dispatch, getState) => { let data; try { data = await client_1.Client4.getDataRetentionCustomPolicies(page, perPage); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch({ type: action_types_1.AdminTypes.RECEIVED_DATA_RETENTION_CUSTOM_POLICIES, error, }); return { error }; } dispatch({ type: action_types_1.AdminTypes.RECEIVED_DATA_RETENTION_CUSTOM_POLICIES, data }); return { data }; }; } function getDataRetentionCustomPolicy(id) { return async (dispatch, getState) => { let data; try { data = await client_1.Client4.getDataRetentionCustomPolicy(id); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch({ type: action_types_1.AdminTypes.RECEIVED_DATA_RETENTION_CUSTOM_POLICY, error, }); return { error }; } dispatch({ type: action_types_1.AdminTypes.RECEIVED_DATA_RETENTION_CUSTOM_POLICY, data }); return { data }; }; } function deleteDataRetentionCustomPolicy(id) { return async (dispatch, getState) => { try { await client_1.Client4.deleteDataRetentionCustomPolicy(id); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch({ type: action_types_1.AdminTypes.DELETE_DATA_RETENTION_CUSTOM_POLICY_FAILURE, error, }); return { error }; } const data = { id, }; dispatch({ type: action_types_1.AdminTypes.DELETE_DATA_RETENTION_CUSTOM_POLICY_SUCCESS, data }); return { data }; }; } function getDataRetentionCustomPolicyTeams(id, page = 0, perPage = constants_1.General.TEAMS_CHUNK_SIZE) { return async (dispatch, getState) => { let data; try { data = await client_1.Client4.getDataRetentionCustomPolicyTeams(id, page, perPage); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch({ type: action_types_1.AdminTypes.RECEIVED_DATA_RETENTION_CUSTOM_POLICY_TEAMS, error, }); return { error }; } dispatch({ type: action_types_1.AdminTypes.RECEIVED_DATA_RETENTION_CUSTOM_POLICY_TEAMS, data }); return { data }; }; } function getDataRetentionCustomPolicyChannels(id, page = 0, perPage = constants_1.General.TEAMS_CHUNK_SIZE) { return async (dispatch, getState) => { let data; try { data = await client_1.Client4.getDataRetentionCustomPolicyChannels(id, page, perPage); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch({ type: action_types_1.AdminTypes.RECEIVED_DATA_RETENTION_CUSTOM_POLICY_CHANNELS, error, }); return { error }; } dispatch({ type: action_types_1.AdminTypes.RECEIVED_DATA_RETENTION_CUSTOM_POLICY_CHANNELS, data }); return { data }; }; } function searchDataRetentionCustomPolicyTeams(id, term, opts) { return async (dispatch, getState) => { let data; try { data = await client_1.Client4.searchDataRetentionCustomPolicyTeams(id, term, opts); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch({ type: action_types_1.AdminTypes.RECEIVED_DATA_RETENTION_CUSTOM_POLICY_TEAMS_SEARCH, error, }); return { error }; } dispatch({ type: action_types_1.AdminTypes.RECEIVED_DATA_RETENTION_CUSTOM_POLICY_TEAMS_SEARCH, data }); return { data }; }; } function searchDataRetentionCustomPolicyChannels(id, term, opts) { return async (dispatch, getState) => { let data; try { data = await client_1.Client4.searchDataRetentionCustomPolicyChannels(id, term, opts); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch({ type: action_types_1.AdminTypes.RECEIVED_DATA_RETENTION_CUSTOM_POLICY_CHANNELS_SEARCH, error, }); return { error }; } dispatch({ type: action_types_1.AdminTypes.RECEIVED_DATA_RETENTION_CUSTOM_POLICY_CHANNELS_SEARCH, data }); return { data }; }; } function createDataRetentionCustomPolicy(policy) { return async (dispatch, getState) => { let data; try { data = await client_1.Client4.createDataRetentionPolicy(policy); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); return { error }; } dispatch({ type: action_types_1.AdminTypes.CREATE_DATA_RETENTION_CUSTOM_POLICY_SUCCESS, data }); return { data }; }; } function updateDataRetentionCustomPolicy(id, policy) { return async (dispatch, getState) => { let data; try { data = await client_1.Client4.updateDataRetentionPolicy(id, policy); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); return { error }; } dispatch({ type: action_types_1.AdminTypes.UPDATE_DATA_RETENTION_CUSTOM_POLICY_SUCCESS, data }); return { data }; }; } function addDataRetentionCustomPolicyTeams(id, teams) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.addDataRetentionPolicyTeams, onSuccess: action_types_1.AdminTypes.ADD_DATA_RETENTION_CUSTOM_POLICY_TEAMS_SUCCESS, params: [ id, teams, ], }); } function removeDataRetentionCustomPolicyTeams(id, teams) { return async (dispatch, getState) => { try { await client_1.Client4.removeDataRetentionPolicyTeams(id, teams); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch({ type: action_types_1.AdminTypes.REMOVE_DATA_RETENTION_CUSTOM_POLICY_TEAMS_FAILURE, error, }); return { error }; } const data = { teams, }; dispatch({ type: action_types_1.AdminTypes.REMOVE_DATA_RETENTION_CUSTOM_POLICY_TEAMS_SUCCESS, data }); return { data }; }; } function addDataRetentionCustomPolicyChannels(id, channels) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.addDataRetentionPolicyChannels, onSuccess: action_types_1.AdminTypes.ADD_DATA_RETENTION_CUSTOM_POLICY_CHANNELS_SUCCESS, params: [ id, channels, ], }); } function removeDataRetentionCustomPolicyChannels(id, channels) { return async (dispatch, getState) => { try { await client_1.Client4.removeDataRetentionPolicyChannels(id, channels); } catch (error) { (0, helpers_1.forceLogoutIfNecessary)(error, dispatch, getState); dispatch({ type: action_types_1.AdminTypes.REMOVE_DATA_RETENTION_CUSTOM_POLICY_CHANNELS_FAILURE, error, }); return { error }; } const data = { channels, }; dispatch({ type: action_types_1.AdminTypes.REMOVE_DATA_RETENTION_CUSTOM_POLICY_CHANNELS_SUCCESS, data }); return { data }; }; } function completeSetup(completeSetup) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.completeSetup, params: [completeSetup], }); } function getAppliedSchemaMigrations() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getAppliedSchemaMigrations, }); } function getIPFilters() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getIPFilters, params: [], }); } function getCurrentIP() { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.getCurrentIP, params: [], }); } function applyIPFilters(ipFilters) { return (0, helpers_1.bindClientFunc)({ clientFunc: client_1.Client4.applyIPFilters, params: [ipFilters], }); }