diff --git a/connection.js b/connection.js index 095edf1e2..b5ab62e9a 100644 --- a/connection.js +++ b/connection.js @@ -17,8 +17,7 @@ import { JitsiConnectionErrors, JitsiConnectionEvents } from './react/features/base/lib-jitsi-meet'; -import { isVpaasMeeting } from './react/features/billing-counter/functions'; -import { getJaasJWT } from './react/features/jaas/functions'; +import { isVpaasMeeting, getJaasJWT } from './react/features/jaas/functions'; import { setPrejoinDisplayNameRequired } from './react/features/prejoin/actions'; const logger = Logger.getLogger(__filename); diff --git a/react/features/app/actions.js b/react/features/app/actions.js index 476116428..3d59cfd89 100644 --- a/react/features/app/actions.js +++ b/react/features/app/actions.js @@ -24,7 +24,7 @@ import { parseURIString, toURLString } from '../base/util'; -import { isVpaasMeeting } from '../billing-counter/functions'; +import { isVpaasMeeting } from '../jaas/functions'; import { clearNotifications, showNotification } from '../notifications'; import { setFatalError } from '../overlay'; diff --git a/react/features/app/middlewares.any.js b/react/features/app/middlewares.any.js index 1b1f6dc7a..dd75af665 100644 --- a/react/features/app/middlewares.any.js +++ b/react/features/app/middlewares.any.js @@ -18,7 +18,6 @@ import '../base/sounds/middleware'; import '../base/testing/middleware'; import '../base/tracks/middleware'; import '../base/user-interaction/middleware'; -import '../billing-counter/middleware'; import '../calendar-sync/middleware'; import '../chat/middleware'; import '../conference/middleware'; diff --git a/react/features/app/reducers.any.js b/react/features/app/reducers.any.js index 7a6741ff0..7a654ee01 100644 --- a/react/features/app/reducers.any.js +++ b/react/features/app/reducers.any.js @@ -25,7 +25,6 @@ import '../base/sounds/reducer'; import '../base/testing/reducer'; import '../base/tracks/reducer'; import '../base/user-interaction/reducer'; -import '../billing-counter/reducer'; import '../calendar-sync/reducer'; import '../chat/reducer'; import '../deep-linking/reducer'; diff --git a/react/features/base/react/components/web/Watermarks.js b/react/features/base/react/components/web/Watermarks.js index afdad18a6..90375d901 100644 --- a/react/features/base/react/components/web/Watermarks.js +++ b/react/features/base/react/components/web/Watermarks.js @@ -2,7 +2,7 @@ import React, { Component } from 'react'; -import { isVpaasMeeting } from '../../../../billing-counter/functions'; +import { isVpaasMeeting } from '../../../../jaas/functions'; import { translate } from '../../../i18n'; import { connect } from '../../../redux'; diff --git a/react/features/billing-counter/actionTypes.js b/react/features/billing-counter/actionTypes.js deleted file mode 100644 index 528faf000..000000000 --- a/react/features/billing-counter/actionTypes.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Action used to store the flag signaling the endpoint has been counted. - */ -export const SET_ENDPOINT_COUNTED = 'SET_ENDPOINT_COUNTED'; diff --git a/react/features/billing-counter/actions.js b/react/features/billing-counter/actions.js deleted file mode 100644 index 2243512b1..000000000 --- a/react/features/billing-counter/actions.js +++ /dev/null @@ -1,42 +0,0 @@ -// @flow - -import { SET_ENDPOINT_COUNTED } from './actionTypes'; -import { extractVpaasTenantFromPath, getBillingId, sendCountRequest } from './functions'; - -/** - * Sends a billing count request when needed. - * - * @returns {Function} - */ -export function countEndpoint() { - return function(dispatch: Function, getState: Function) { - const state = getState(); - const baseUrl = state['features/base/config'].billingCounterUrl; - const jwt = state['features/base/jwt'].jwt; - const tenant = extractVpaasTenantFromPath(state['features/base/connection'].locationURL.pathname); - const shouldSendRequest = Boolean(baseUrl && jwt && tenant); - - if (shouldSendRequest) { - const billingId = getBillingId(); - - sendCountRequest({ - baseUrl, - billingId, - jwt, - tenant - }); - dispatch(setEndpointCounted()); - } - }; -} - -/** - * Action used to mark the endpoint as counted. - * - * @returns {Object} - */ -function setEndpointCounted() { - return { - type: SET_ENDPOINT_COUNTED - }; -} diff --git a/react/features/billing-counter/constants.js b/react/features/billing-counter/constants.js deleted file mode 100644 index 4703198e9..000000000 --- a/react/features/billing-counter/constants.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * The key for the billing id stored in localStorage. - */ -export const BILLING_ID = 'jitsiMeetId'; - -/** - * The prefix for the vpaas tenant. - */ -export const VPAAS_TENANT_PREFIX = 'vpaas-magic-cookie-'; diff --git a/react/features/billing-counter/functions.js b/react/features/billing-counter/functions.js deleted file mode 100644 index 3f3a56938..000000000 --- a/react/features/billing-counter/functions.js +++ /dev/null @@ -1,112 +0,0 @@ -// @flow - -import { jitsiLocalStorage } from '@jitsi/js-utils'; -import uuid from 'uuid'; - -import { BILLING_ID, VPAAS_TENANT_PREFIX } from './constants'; -import logger from './logger'; - -/** - * Returns the full vpaas tenant if available, given a path. - * - * @param {string} path - The meeting url path. - * @returns {string} - */ -export function extractVpaasTenantFromPath(path: string) { - const [ , tenant ] = path.split('/'); - - if (tenant.startsWith(VPAAS_TENANT_PREFIX)) { - return tenant; - } - - return ''; -} - -/** - * Returns the vpaas tenant. - * - * @param {Object} state - The global state. - * @returns {string} - */ -export function getVpaasTenant(state: Object) { - return extractVpaasTenantFromPath(state['features/base/connection'].locationURL.pathname); -} - -/** - * Returns true if the current meeting is a vpaas one. - * - * @param {Object} state - The state of the app. - * @returns {boolean} - */ -export function isVpaasMeeting(state: Object) { - const { billingCounterUrl } = state['features/base/config']; - - return Boolean( - billingCounterUrl - && extractVpaasTenantFromPath( - state['features/base/connection'].locationURL.pathname) - ); -} - -/** - * Sends a billing counter request. - * - * @param {Object} reqData - The request info. - * @param {string} reqData.baseUrl - The base url for the request. - * @param {string} billingId - The unique id of the client. - * @param {string} jwt - The JWT token. - * @param {string} tenat - The client tenant. - * @returns {void} - */ -export async function sendCountRequest({ baseUrl, billingId, jwt, tenant }: { - baseUrl: string, - billingId: string, - jwt: string, - tenant: string -}) { - const fullUrl = `${baseUrl}/${encodeURIComponent(tenant)}/${billingId}`; - const headers = { - 'Authorization': `Bearer ${jwt}` - }; - - try { - const res = await fetch(fullUrl, { - method: 'GET', - headers - }); - - if (!res.ok) { - logger.error('Status error:', res.status); - } - } catch (err) { - logger.error('Could not send request', err); - } -} - -/** - * Returns the stored billing id (or generates a new one if none is present). - * - * @returns {string} - */ -export function getBillingId() { - let billingId = jitsiLocalStorage.getItem(BILLING_ID); - - if (!billingId) { - billingId = uuid.v4(); - jitsiLocalStorage.setItem(BILLING_ID, billingId); - } - - return billingId; -} - -/** - * Returns the billing id for vpaas meetings. - * - * @param {Object} state - The state of the app. - * @returns {string | undefined} - */ -export function getVpaasBillingId(state: Object) { - if (isVpaasMeeting(state)) { - return getBillingId(); - } -} diff --git a/react/features/billing-counter/logger.js b/react/features/billing-counter/logger.js deleted file mode 100644 index b450e6154..000000000 --- a/react/features/billing-counter/logger.js +++ /dev/null @@ -1,5 +0,0 @@ -// @flow - -import { getLogger } from '../base/logging/functions'; - -export default getLogger('features/billing-counter'); diff --git a/react/features/billing-counter/reducer.js b/react/features/billing-counter/reducer.js deleted file mode 100644 index 70cb517cf..000000000 --- a/react/features/billing-counter/reducer.js +++ /dev/null @@ -1,29 +0,0 @@ -import { ReducerRegistry } from '../base/redux'; - -import { - SET_ENDPOINT_COUNTED -} from './actionTypes'; - -const DEFAULT_STATE = { - endpointCounted: false -}; - -/** - * Listen for actions that mutate the billing-counter state - */ -ReducerRegistry.register( - 'features/billing-counter', (state = DEFAULT_STATE, action) => { - switch (action.type) { - - case SET_ENDPOINT_COUNTED: { - return { - ...state, - endpointCounted: true - }; - } - - default: - return state; - } - }, -); diff --git a/react/features/chrome-extension-banner/components/ChromeExtensionBanner.web.js b/react/features/chrome-extension-banner/components/ChromeExtensionBanner.web.js index 903bfa28e..f37e5ba96 100644 --- a/react/features/chrome-extension-banner/components/ChromeExtensionBanner.web.js +++ b/react/features/chrome-extension-banner/components/ChromeExtensionBanner.web.js @@ -16,7 +16,7 @@ import { translate } from '../../base/i18n'; import { Icon, IconClose } from '../../base/icons'; import { browser } from '../../base/lib-jitsi-meet'; import { connect } from '../../base/redux'; -import { isVpaasMeeting } from '../../billing-counter/functions'; +import { isVpaasMeeting } from '../../jaas/functions'; import logger from '../logger'; diff --git a/react/features/conference/functions.web.js b/react/features/conference/functions.web.js index e971ced20..2b9aa3916 100644 --- a/react/features/conference/functions.web.js +++ b/react/features/conference/functions.web.js @@ -4,7 +4,6 @@ import { translateToHTML } from '../base/i18n'; import { getLocalParticipant } from '../base/participants'; import { toState } from '../base/redux'; import { getBackendSafePath, getJitsiMeetGlobalNS } from '../base/util'; -import { getVpaasBillingId } from '../billing-counter/functions'; import { showWarningNotification } from '../notifications'; import { createRnnoiseProcessor } from '../stream-effects/rnnoise'; @@ -85,7 +84,6 @@ export function getConferenceOptions(stateful) { options.applicationName = getName(); options.getWiFiStatsMethod = getWiFiStatsMethod; options.createVADProcessor = createRnnoiseProcessor; - options.billingId = getVpaasBillingId(state); // Disable CallStats, if requessted. if (options.disableThirdPartyRequests) { diff --git a/react/features/deep-linking/functions.js b/react/features/deep-linking/functions.js index 9805d1421..bf604543c 100644 --- a/react/features/deep-linking/functions.js +++ b/react/features/deep-linking/functions.js @@ -3,7 +3,7 @@ import { isMobileBrowser } from '../base/environment/utils'; import { Platform } from '../base/react'; import { URI_PROTOCOL_PATTERN } from '../base/util'; -import { isVpaasMeeting } from '../billing-counter/functions'; +import { isVpaasMeeting } from '../jaas/functions'; import { DeepLinkingDesktopPage, diff --git a/react/features/feedback/actions.js b/react/features/feedback/actions.js index eee0ca77b..3d96ddd06 100644 --- a/react/features/feedback/actions.js +++ b/react/features/feedback/actions.js @@ -4,8 +4,8 @@ import type { Dispatch } from 'redux'; import { FEEDBACK_REQUEST_IN_PROGRESS } from '../../../modules/UI/UIErrors'; import { openDialog } from '../base/dialog'; -import { isVpaasMeeting } from '../billing-counter/functions'; import { extractFqnFromPath } from '../dynamic-branding/functions'; +import { isVpaasMeeting } from '../jaas/functions'; import { CANCEL_FEEDBACK, diff --git a/react/features/invite/components/add-people-dialog/web/AddPeopleDialog.js b/react/features/invite/components/add-people-dialog/web/AddPeopleDialog.js index bbb87d560..c7e7b3d4e 100644 --- a/react/features/invite/components/add-people-dialog/web/AddPeopleDialog.js +++ b/react/features/invite/components/add-people-dialog/web/AddPeopleDialog.js @@ -8,9 +8,9 @@ import { Dialog } from '../../../../base/dialog'; import { translate } from '../../../../base/i18n'; import { JitsiRecordingConstants } from '../../../../base/lib-jitsi-meet'; import { connect } from '../../../../base/redux'; -import { isVpaasMeeting } from '../../../../billing-counter/functions'; import { isDynamicBrandingDataLoaded } from '../../../../dynamic-branding/functions'; import EmbedMeetingTrigger from '../../../../embed-meeting/components/EmbedMeetingTrigger'; +import { isVpaasMeeting } from '../../../../jaas/functions'; import { getActiveSession } from '../../../../recording'; import { updateDialInNumbers } from '../../../actions'; import { diff --git a/react/features/invite/components/add-people-dialog/web/InviteContactsForm.js b/react/features/invite/components/add-people-dialog/web/InviteContactsForm.js index 0bb0dff06..43f8af9ea 100644 --- a/react/features/invite/components/add-people-dialog/web/InviteContactsForm.js +++ b/react/features/invite/components/add-people-dialog/web/InviteContactsForm.js @@ -10,7 +10,7 @@ import { Icon, IconPhone } from '../../../../base/icons'; import { getLocalParticipant } from '../../../../base/participants'; import { MultiSelectAutocomplete } from '../../../../base/react'; import { connect } from '../../../../base/redux'; -import { isVpaasMeeting } from '../../../../billing-counter/functions'; +import { isVpaasMeeting } from '../../../../jaas/functions'; import { hideAddPeopleDialog } from '../../../actions'; import { INVITE_TYPES } from '../../../constants'; import AbstractAddPeopleDialog, { diff --git a/react/features/invite/functions.js b/react/features/invite/functions.js index 7f90da56d..d2436ff21 100644 --- a/react/features/invite/functions.js +++ b/react/features/invite/functions.js @@ -9,7 +9,7 @@ import { JitsiRecordingConstants } from '../base/lib-jitsi-meet'; import { getLocalParticipant, isLocalParticipantModerator } from '../base/participants'; import { toState } from '../base/redux'; import { doGetJSON, parseURIString } from '../base/util'; -import { isVpaasMeeting } from '../billing-counter/functions'; +import { isVpaasMeeting } from '../jaas/functions'; import { INVITE_TYPES, SIP_ADDRESS_REGEX } from './constants'; import logger from './logger'; diff --git a/react/features/jaas/actions.web.js b/react/features/jaas/actions.web.js index 7fec5d301..ec8bb3690 100644 --- a/react/features/jaas/actions.web.js +++ b/react/features/jaas/actions.web.js @@ -1,12 +1,11 @@ // @flow import { openDialog } from '../base/dialog'; -import { VPAAS_TENANT_PREFIX } from '../billing-counter/constants'; -import { getVpaasTenant } from '../billing-counter/functions'; import { SET_DETAILS } from './actionTypes'; import { PremiumFeatureDialog } from './components'; -import { isFeatureDisabled, sendGetDetailsRequest } from './functions'; +import { VPAAS_TENANT_PREFIX } from './constants'; +import { getVpaasTenant, isFeatureDisabled, sendGetDetailsRequest } from './functions'; import logger from './logger'; /** diff --git a/react/features/jaas/constants.js b/react/features/jaas/constants.js index c312ede65..c2319ee0f 100644 --- a/react/features/jaas/constants.js +++ b/react/features/jaas/constants.js @@ -23,3 +23,8 @@ export const FEATURES = { * URL for displaying JaaS upgrade options */ export const JAAS_UPGRADE_URL = 'https://jaas.8x8.vc/#/plan/upgrade'; + +/** + * The prefix for the vpaas tenant. + */ +export const VPAAS_TENANT_PREFIX = 'vpaas-magic-cookie-'; diff --git a/react/features/jaas/functions.js b/react/features/jaas/functions.js index 375cf2078..1984a8185 100644 --- a/react/features/jaas/functions.js +++ b/react/features/jaas/functions.js @@ -1,9 +1,53 @@ // @flow -import { getVpaasTenant } from '../billing-counter/functions'; +import { VPAAS_TENANT_PREFIX } from './constants'; import logger from './logger'; +/** + * Returns the full vpaas tenant if available, given a path. + * + * @param {string} path - The meeting url path. + * @returns {string} + */ +function extractVpaasTenantFromPath(path: string) { + const [ , tenant ] = path.split('/'); + + if (tenant.startsWith(VPAAS_TENANT_PREFIX)) { + return tenant; + } + + return ''; +} + +/** + * Returns the vpaas tenant. + * + * @param {Object} state - The global state. + * @returns {string} + */ +export function getVpaasTenant(state: Object) { + return extractVpaasTenantFromPath(state['features/base/connection'].locationURL.pathname); +} + +/** + * Returns true if the current meeting is a vpaas one. + * + * @param {Object} state - The state of the app. + * @returns {boolean} + */ +export function isVpaasMeeting(state: Object) { + const connection = state['features/base/connection']; + + if (connection?.locationURL?.pathname) { + return Boolean( + extractVpaasTenantFromPath(connection?.locationURL?.pathname) + ); + } + + return false; +} + /** * Sends a request for retrieving jaas customer details. * diff --git a/react/features/billing-counter/middleware.js b/react/features/jaas/middleware.any.js similarity index 59% rename from react/features/billing-counter/middleware.js rename to react/features/jaas/middleware.any.js index 1df02ec50..d0263c66a 100644 --- a/react/features/billing-counter/middleware.js +++ b/react/features/jaas/middleware.any.js @@ -1,10 +1,8 @@ import { sendAnalytics, createVpaasConferenceJoinedEvent } from '../analytics'; import { CONFERENCE_JOINED } from '../base/conference/actionTypes'; -import { PARTICIPANT_JOINED } from '../base/participants/actionTypes'; import { MiddlewareRegistry } from '../base/redux'; -import { countEndpoint } from './actions'; -import { isVpaasMeeting, extractVpaasTenantFromPath } from './functions'; +import { isVpaasMeeting, getVpaasTenant } from './functions'; /** * The redux middleware for billing counter. @@ -20,17 +18,6 @@ MiddlewareRegistry.register(store => next => async action => { break; } - - case PARTICIPANT_JOINED: { - const shouldCount = !store.getState()['features/billing-counter'].endpointCounted - && !action.participant.local; - - if (shouldCount) { - store.dispatch(countEndpoint()); - } - - break; - } } return next(action); @@ -45,7 +32,6 @@ MiddlewareRegistry.register(store => next => async action => { function _maybeTrackVpaasConferenceJoin(state) { if (isVpaasMeeting(state)) { sendAnalytics(createVpaasConferenceJoinedEvent( - extractVpaasTenantFromPath( - state['features/base/connection'].locationURL.pathname))); + getVpaasTenant(state))); } } diff --git a/react/features/jaas/middleware.web.js b/react/features/jaas/middleware.web.js index 1e7bfb012..4fa4adccd 100644 --- a/react/features/jaas/middleware.web.js +++ b/react/features/jaas/middleware.web.js @@ -3,11 +3,12 @@ import { CONFERENCE_JOINED } from '../base/conference/actionTypes'; import { CONNECTION_FAILED } from '../base/connection'; import { JitsiConnectionErrors } from '../base/lib-jitsi-meet'; import { MiddlewareRegistry } from '../base/redux'; -import { isVpaasMeeting } from '../billing-counter/functions'; + import { SET_DETAILS } from './actionTypes'; import { getCustomerDetails } from './actions'; import { STATUSES } from './constants'; +import { isVpaasMeeting } from './functions'; /** * The redux middleware for jaas. diff --git a/react/features/reactions/middleware.js b/react/features/reactions/middleware.js index aefbeb183..cc1cf2a5b 100644 --- a/react/features/reactions/middleware.js +++ b/react/features/reactions/middleware.js @@ -2,7 +2,7 @@ import { ENDPOINT_REACTION_NAME } from '../../../modules/API/constants'; import { MiddlewareRegistry } from '../base/redux'; -import { isVpaasMeeting } from '../billing-counter/functions'; +import { isVpaasMeeting } from '../jaas/functions'; import { SET_REACTIONS_MESSAGE, diff --git a/react/features/recording/actions.any.js b/react/features/recording/actions.any.js index 7bdcf2eec..141415d18 100644 --- a/react/features/recording/actions.any.js +++ b/react/features/recording/actions.any.js @@ -4,7 +4,7 @@ import { getMeetingRegion, getRecordingSharingUrl } from '../base/config'; import JitsiMeetJS, { JitsiRecordingConstants } from '../base/lib-jitsi-meet'; import { getLocalParticipant, getParticipantDisplayName } from '../base/participants'; import { copyText } from '../base/util/helpers'; -import { getVpaasTenant, isVpaasMeeting } from '../billing-counter/functions'; +import { getVpaasTenant, isVpaasMeeting } from '../jaas/functions'; import { NOTIFICATION_TIMEOUT, hideNotification, diff --git a/react/features/recording/components/Recording/StartRecordingDialogContent.js b/react/features/recording/components/Recording/StartRecordingDialogContent.js index 1e5fef9bb..1db16ae5c 100644 --- a/react/features/recording/components/Recording/StartRecordingDialogContent.js +++ b/react/features/recording/components/Recording/StartRecordingDialogContent.js @@ -21,8 +21,8 @@ import { } from '../../../base/react'; import { connect } from '../../../base/redux'; import { ColorPalette, StyleType } from '../../../base/styles'; -import { isVpaasMeeting } from '../../../billing-counter/functions'; import { authorizeDropbox, updateDropboxToken } from '../../../dropbox'; +import { isVpaasMeeting } from '../../../jaas/functions'; import { RECORDING_TYPES } from '../../constants'; import { getRecordingDurationEstimation } from '../../functions'; diff --git a/react/features/toolbox/components/DownloadButton.js b/react/features/toolbox/components/DownloadButton.js index 30bb1dfba..dfc40ad32 100644 --- a/react/features/toolbox/components/DownloadButton.js +++ b/react/features/toolbox/components/DownloadButton.js @@ -6,7 +6,7 @@ import { IconDownload } from '../../base/icons'; import { connect } from '../../base/redux'; import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components'; import { openURLInBrowser } from '../../base/util'; -import { isVpaasMeeting } from '../../billing-counter/functions'; +import { isVpaasMeeting } from '../../jaas/functions'; type Props = AbstractButtonProps & { diff --git a/react/features/toolbox/components/HelpButton.js b/react/features/toolbox/components/HelpButton.js index 53b7c2cad..33a2edf30 100644 --- a/react/features/toolbox/components/HelpButton.js +++ b/react/features/toolbox/components/HelpButton.js @@ -7,7 +7,7 @@ import { IconHelp } from '../../base/icons'; import { connect } from '../../base/redux'; import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components'; import { openURLInBrowser } from '../../base/util'; -import { isVpaasMeeting } from '../../billing-counter/functions'; +import { isVpaasMeeting } from '../../jaas/functions'; type Props = AbstractButtonProps & { diff --git a/react/features/toolbox/components/web/Toolbox.js b/react/features/toolbox/components/web/Toolbox.js index b53ed6a46..5b6775422 100644 --- a/react/features/toolbox/components/web/Toolbox.js +++ b/react/features/toolbox/components/web/Toolbox.js @@ -22,12 +22,12 @@ import { } from '../../../base/participants'; import { connect } from '../../../base/redux'; import { getLocalVideoTrack } from '../../../base/tracks'; -import { isVpaasMeeting } from '../../../billing-counter/functions'; import { toggleChat } from '../../../chat'; import { ChatButton } from '../../../chat/components'; import { EmbedMeetingButton } from '../../../embed-meeting'; import { SharedDocumentButton } from '../../../etherpad'; import { FeedbackButton } from '../../../feedback'; +import { isVpaasMeeting } from '../../../jaas/functions'; import { KeyboardShortcutsButton } from '../../../keyboard-shortcuts'; import { LocalRecordingButton } from '../../../local-recording'; import {