Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dynamic-branding): New options for URLs in config #15373

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions react/features/base/config/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AnyAction } from 'redux';

import { IStore } from '../../app/types';
import { SET_DYNAMIC_BRANDING_DATA } from '../../dynamic-branding/actionTypes';
import { getFeatureFlag } from '../flags/functions';
import MiddlewareRegistry from '../redux/MiddlewareRegistry';
import { updateSettings } from '../settings/actions';
Expand All @@ -21,8 +22,12 @@ MiddlewareRegistry.register(store => next => action => {
case SET_CONFIG:
return _setConfig(store, next, action);

case SET_DYNAMIC_BRANDING_DATA:
return _setDynamicBrandingData(store, next, action);

case OVERWRITE_CONFIG:
return _updateSettings(store, next, action);

}

return next(action);
Expand Down Expand Up @@ -94,6 +99,79 @@ function _setConfig({ dispatch, getState }: IStore, next: Function, action: AnyA
return result;
}

/**
* Updates config based on dynamic branding data.
*
* @param {Store} store - The redux store in which the specified {@code action}
* is being dispatched.
* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
* specified {@code action} in the specified {@code store}.
* @param {Action} action - The redux action which is being {@code dispatch}ed
* in the specified {@code store}.
* @private
* @returns {*} The return value of {@code next(action)}.
*/
function _setDynamicBrandingData({ dispatch }: IStore, next: Function, action: AnyAction) {
const config: IConfig = {};
const {
downloadAppsUrl,
liveStreamingDialogUrls = {},
preCallTest = {},
salesforceUrl,
userDocumentationUrl
} = action.value;

const { helpUrl, termsUrl, dataPrivacyUrl } = liveStreamingDialogUrls;

if (helpUrl || termsUrl || dataPrivacyUrl) {
config.liveStreaming = {};
if (helpUrl) {
config.liveStreaming.helpLink = helpUrl;
}

if (termsUrl) {
config.liveStreaming.termsLink = termsUrl;
}

if (dataPrivacyUrl) {
config.liveStreaming.dataPrivacyLink = dataPrivacyUrl;
}
}

if (downloadAppsUrl || userDocumentationUrl) {
config.deploymentUrls = {};

if (downloadAppsUrl) {
config.deploymentUrls.downloadAppsUrl = downloadAppsUrl;
}

if (userDocumentationUrl) {
config.deploymentUrls.userDocumentationURL = userDocumentationUrl;
}
}

if (salesforceUrl) {
config.salesforceUrl = salesforceUrl;
}

const { enabled, iceUrl } = preCallTest;

if (typeof enabled === 'boolean') {
config.prejoinConfig = {
preCallTestEnabled: enabled
};
}

if (iceUrl) {
config.prejoinConfig = config.prejoinConfig || {};
config.prejoinConfig.preCallTestICEUrl = iceUrl;
}

dispatch(updateConfig(config));

return next(action);
}

/**
* Updates settings based on some config values.
*
Expand Down
12 changes: 10 additions & 2 deletions react/features/dynamic-branding/middleware.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ MiddlewareRegistry.register(store => next => action => {
backgroundImageUrl,
brandedIcons,
didPageUrl,
downloadAppsUrl,
inviteDomain,
labels,
liveStreamingDialogUrls,
salesforceUrl,
sharedVideoAllowedURLDomains,
supportUrl
supportUrl,
userDocumentationUrl
} = action.value;

action.value = {
Expand All @@ -35,10 +39,14 @@ MiddlewareRegistry.register(store => next => action => {
backgroundImageUrl,
brandedIcons,
didPageUrl,
downloadAppsUrl,
inviteDomain,
labels,
liveStreamingDialogUrls,
salesforceUrl,
sharedVideoAllowedURLDomains,
supportUrl
supportUrl,
userDocumentationUrl
};

// The backend may send an empty string, make sure we skip that.
Expand Down
Loading