Skip to content

Commit

Permalink
fix(branding): Use config url for dynamic branding
Browse files Browse the repository at this point in the history
  • Loading branch information
vp8x8 authored and saghul committed Dec 18, 2020
1 parent 27d4160 commit 33e4324
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ var config = {
logoImageUrl: 'https://example.com/logo-img.png'
}
*/
// brandingDataUrl: '',
// dynamicBrandingUrl: '',

// The URL of the moderated rooms microservice, if available. If it
// is present, a link to the service will be rendered on the welcome page,
Expand Down
10 changes: 5 additions & 5 deletions react/features/dynamic-branding/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import {
SET_DYNAMIC_BRANDING_FAILED,
SET_DYNAMIC_BRANDING_READY
} from './actionTypes';
import { extractFqnFromPath } from './functions';
import { getDynamicBrandingUrl } from './functions';

const logger = getLogger(__filename);


/**
* Fetches custom branding data.
* If there is no data or the request fails, sets the `customizationReady` flag
Expand All @@ -23,15 +24,14 @@ const logger = getLogger(__filename);
export function fetchCustomBrandingData() {
return async function(dispatch: Function, getState: Function) {
const state = getState();
const baseUrl = state['features/base/config'].brandingDataUrl;
const { customizationReady } = state['features/dynamic-branding'];

if (!customizationReady) {
const fqn = extractFqnFromPath(state['features/base/connection'].locationURL.pathname);
const url = getDynamicBrandingUrl(state);

if (baseUrl && fqn) {
if (url) {
try {
const res = await doGetJSON(`${baseUrl}?conferenceFqn=${encodeURIComponent(fqn)}`);
const res = await doGetJSON(url);

return dispatch(setDynamicBrandingData(res));
} catch (err) {
Expand Down
21 changes: 21 additions & 0 deletions react/features/dynamic-branding/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,24 @@ export function extractFqnFromPath(path: string) {

return parts.length > 2 ? `${parts[len - 2]}/${parts[len - 1]}` : '';
}

/**
* Returns the url used for fetching dynamic branding.
*
* @param {Object} state - The state of the app.
* @returns {string}
*/
export function getDynamicBrandingUrl(state: Object) {
const { dynamicBrandingUrl } = state['features/base/config'];

if (dynamicBrandingUrl) {
return dynamicBrandingUrl;
}

const baseUrl = state['features/base/config'].brandingDataUrl;
const fqn = extractFqnFromPath(state['features/base/connection'].locationURL.pathname);

if (baseUrl && fqn) {
return `${baseUrl}?conferenceFqn=${encodeURIComponent(fqn)}`;
}
}

0 comments on commit 33e4324

Please sign in to comment.