From 7def76c0c752e1a8b37999748b78399854517565 Mon Sep 17 00:00:00 2001 From: Ramon Souza <contato@ramonsouza.com> Date: Mon, 2 Aug 2021 17:08:32 -0300 Subject: [PATCH] get overrideLocale param from api --- .../private/static/guest-wait/guest-wait.html | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/bigbluebutton-html5/private/static/guest-wait/guest-wait.html b/bigbluebutton-html5/private/static/guest-wait/guest-wait.html index d4f93f5837..e3de1143b8 100755 --- a/bigbluebutton-html5/private/static/guest-wait/guest-wait.html +++ b/bigbluebutton-html5/private/static/guest-wait/guest-wait.html @@ -110,11 +110,45 @@ }); }; - function fetchLocalizedMessages() { + async function fetchOverrideLocale() { + const token = findSessionToken(); + let overrideLocale = false; + + if (token) { + const sessionToken = token.split('=')[1]; + + // use enter api to get params for the client + const ENTER_ENDPOINT = `/bigbluebutton/api/enter?sessionToken=${sessionToken}`; + const url = new URL(`${window.location.origin}${ENTER_ENDPOINT}`); + + const fetchContent = await fetch(url, { credentials: 'same-origin' }); + const parseToJson = await fetchContent.json(); + const { response } = parseToJson; + + if (response.returncode !== 'FAILED') { + const { customdata } = response; + + customdata.forEach((el) => { + const settingKey = Object.keys(el).shift(); + + if (settingKey === 'bbb_override_default_locale') { + overrideLocale = el[settingKey]; + } + }); + } + } + return overrideLocale; + } + + async function fetchLocalizedMessages() { const DEFAULT_LANGUAGE = 'en'; const LOCALES_ENDPOINT = '/html5client/locale'; const url = new URL(`${window.location.origin}${LOCALES_ENDPOINT}`); - url.search = `locale=${navigator.language}&init=true`; + const overrideLocale = await fetchOverrideLocale(); + + url.search = overrideLocale + ? `locale=${overrideLocale}` + : `locale=${navigator.language}&init=true`; const localesPath = 'locales'; -- GitLab