Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
[RN] If calendar-sync knows a domain, then the app knows it
Zoltan Bettenbuk46bc63b79e3e
diff --git a/react/features/calendar-sync/actionTypes.js b/react/features/calendar-sync/actionTypes.jsindex b664853f22..1d98fe0de1 100644--- a/react/features/calendar-sync/actionTypes.js+++ b/react/features/calendar-sync/actionTypes.js@@ -1,16 +1,5 @@// @flow-/**- * Action to add a new domain to the list of domain known to the feature- * calendar-sync.- *- * {- * type: ADD_KNOWN_DOMAIN,- * knownDomain: string- * }- */-export const ADD_KNOWN_DOMAIN = Symbol('ADD_KNOWN_DOMAIN');-/*** Action to refresh (re-fetch) the entry list.*diff --git a/react/features/calendar-sync/actions.js b/react/features/calendar-sync/actions.jsindex eb47229025..3c3950958e 100644--- a/react/features/calendar-sync/actions.js+++ b/react/features/calendar-sync/actions.js@@ -3,26 +3,9 @@import {SET_CALENDAR_AUTHORIZATION,SET_CALENDAR_EVENTS,- ADD_KNOWN_DOMAIN,REFRESH_CALENDAR} from './actionTypes';-/**- * Sends an action to add a new known domain if not present yet.- *- * @param {string} knownDomain - The new domain.- * @returns {{- * type: ADD_KNOWN_DOMAIN,- * knownDomain: string- * }}- */-export function addKnownDomain(knownDomain: string) {- return {- type: ADD_KNOWN_DOMAIN,- knownDomain- };-}-/*** Sends an action to refresh the entry list (fetches new data).*diff --git a/react/features/calendar-sync/middleware.js b/react/features/calendar-sync/middleware.jsindex 7ac8a6a62a..10fc963ab3 100644--- a/react/features/calendar-sync/middleware.js+++ b/react/features/calendar-sync/middleware.js@@ -3,13 +3,12 @@import RNCalendarEvents from 'react-native-calendar-events';import { APP_WILL_MOUNT } from '../app';-import { SET_ROOM } from '../base/conference';+import { ADD_KNOWN_DOMAINS } from '../base/domains';import { MiddlewareRegistry } from '../base/redux';import { APP_LINK_SCHEME, parseURIString } from '../base/util';import { APP_STATE_CHANGED } from '../mobile/background';import {- addKnownDomain,setCalendarAuthorization,setCalendarEvents} from './actions';@@ -18,8 +17,19 @@ import { CALENDAR_ENABLED } from './constants';const logger = require('jitsi-meet-logger').getLogger(__filename);+/**+ * The no. of days to fetch.+ */const FETCH_END_DAYS = 10;++/**+ * The no. of days to go back when fetching.+ */const FETCH_START_DAYS = -1;++/**+ * The max number of events to fetch from the calendar.+ */const MAX_LIST_LENGTH = 10;CALENDAR_ENABLED@@ -31,18 +41,14 @@ CALENDAR_ENABLED_maybeClearAccessStatus(store, action);break;+ case ADD_KNOWN_DOMAINS:case APP_WILL_MOUNT:- _ensureDefaultServer(store);_fetchCalendarEntries(store, false, false);break;case REFRESH_CALENDAR:_fetchCalendarEntries(store, true, action.forcePermission);break;-- case SET_ROOM:- _parseAndAddKnownDomain(store);- break;}return result;@@ -95,20 +101,6 @@ function _ensureCalendarAccess(promptForPermission, dispatch) {});}-/**- * Ensures presence of the default server in the known domains list.- *- * @param {Object} store - The redux store.- * @private- * @returns {Promise}- */-function _ensureDefaultServer({ dispatch, getState }) {- const defaultURL- = parseURIString(getState()['features/app'].app._getDefaultURL());-- dispatch(addKnownDomain(defaultURL.host));-}-/*** Reads the user's calendar and updates the stored entries if need be.*@@ -124,9 +116,10 @@ function _fetchCalendarEntries({ dispatch, getState },maybePromptForPermission,forcePermission) {- const state = getState()['features/calendar-sync'];+ const featureState = getState()['features/calendar-sync'];+ const knownDomains = getState()['features/base/domains'];const promptForPermission- = (maybePromptForPermission && !state.authorization)+ = (maybePromptForPermission && !featureState.authorization)|| forcePermission;_ensureCalendarAccess(promptForPermission, dispatch)@@ -145,7 +138,7 @@ function _fetchCalendarEntries(.then(events =>_updateCalendarEntries(events,- state.knownDomains,+ knownDomains,dispatch)).catch(error =>logger.error('Error fetching calendar.', error));@@ -199,20 +192,6 @@ function _getURLFromEvent(event, knownDomains) {return null;}-/**- * Retrieves the domain name of a room upon join and stores it in the known- * domain list, if not present yet.- *- * @param {Object} store - The redux store.- * @private- * @returns {Promise}- */-function _parseAndAddKnownDomain({ dispatch, getState }) {- const { locationURL } = getState()['features/base/connection'];-- dispatch(addKnownDomain(locationURL.host));-}-/*** Updates the calendar entries in Redux when new list is received.*diff --git a/react/features/calendar-sync/reducer.js b/react/features/calendar-sync/reducer.jsindex d76fb93cad..00c348f894 100644--- a/react/features/calendar-sync/reducer.js+++ b/react/features/calendar-sync/reducer.js@@ -1,10 +1,8 @@// @flowimport { ReducerRegistry } from '../base/redux';-import { PersistenceRegistry } from '../base/storage';import {- ADD_KNOWN_DOMAIN,SET_CALENDAR_AUTHORIZATION,SET_CALENDAR_EVENTS} from './actionTypes';@@ -17,24 +15,14 @@ const DEFAULT_STATE = {* need to re-request the calendar permission from the user.*/authorization: undefined,- events: [],- knownDomains: []+ events: []};-const MAX_DOMAIN_LIST_SIZE = 10;-const STORE_NAME = 'features/calendar-sync';-CALENDAR_ENABLED- && PersistenceRegistry.register(STORE_NAME, {- knownDomains: true- });-CALENDAR_ENABLED&& ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {switch (action.type) {- case ADD_KNOWN_DOMAIN:- return _addKnownDomain(state, action);case SET_CALENDAR_AUTHORIZATION:return {@@ -52,41 +40,3 @@ CALENDAR_ENABLEDreturn state;}});--/**- * Adds a new domain to the known domain list if not present yet.- *- * @param {Object} state - The redux state.- * @param {Object} action - The redux action.- * @private- * @returns {Object}- */-function _addKnownDomain(state, action) {- let { knownDomain } = action;-- if (knownDomain) {- knownDomain = knownDomain.toLowerCase();-- let { knownDomains } = state;-- if (knownDomains.indexOf(knownDomain) === -1) {- // Add the specified known domain and at the same time avoid- // modifying the knownDomains Array instance referenced by the- // current redux state.- knownDomains = [- ...state.knownDomains,- knownDomain- ];-- // Ensure the list doesn't exceed a/the maximum size.- knownDomains.splice(0, knownDomains.length - MAX_DOMAIN_LIST_SIZE);-- return {- ...state,- knownDomains- };- }- }-- return state;-}