Merge pull request #20091 from ramonlsouza/remove-makecall

refactor: Remove remaining makecall
This commit is contained in:
Tiago Jacobs 2024-04-25 16:36:43 -03:00 committed by GitHub
commit 023a7b1e4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 38 additions and 483 deletions

View File

@ -22,7 +22,6 @@ import { Meteor } from 'meteor/meteor';
import logger from '/imports/startup/client/logger';
import '/imports/ui/services/mobile-app';
import Base from '/imports/startup/client/base';
import JoinHandler from '../imports/ui/components/join-handler/component';
import Subscriptions from '/imports/ui/components/subscriptions/component';
import IntlStartup from '/imports/startup/client/intl';
import ContextProviders from '/imports/ui/components/context-providers/component';

View File

@ -1,10 +1,8 @@
import { Meteor } from 'meteor/meteor';
import setUserEffectiveConnectionType from './methods/setUserEffectiveConnectionType';
import userActivitySign from './methods/userActivitySign';
import validateConnection from './methods/validateConnection';
Meteor.methods({
validateConnection,
setUserEffectiveConnectionType,
userActivitySign,
});

View File

@ -1,40 +0,0 @@
import { Meteor } from 'meteor/meteor';
import Users from '/imports/api/users';
import RedisPubSub from '/imports/startup/server/redis';
import Logger from '/imports/startup/server/logger';
import { extractCredentials } from '/imports/api/common/server/helpers';
import { check } from 'meteor/check';
export default async function userActivitySign() {
try {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'UserActivitySignCmdMsg';
const { meetingId, requesterUserId: userId } = extractCredentials(this.userId);
check(meetingId, String);
check(userId, String);
const payload = {
userId,
};
const selector = {
userId,
};
const modifier = {
$set: {
inactivityCheck: false,
},
};
await Users.updateAsync(selector, modifier); // TODO-- we should move this to a modifier
Logger.info(`User ${userId} sent a activity sign for meeting ${meetingId}`);
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload);
} catch (err) {
Logger.error(`Exception while invoking method userActivitySign ${err.stack}`);
}
}

View File

@ -1,6 +1,5 @@
import Auth from '/imports/ui/services/auth';
import Users from '/imports/api/users';
import { makeCall } from '/imports/ui/services/api';
import Meetings from '/imports/api/meetings';
import Breakouts from '/imports/api/breakouts';
@ -22,7 +21,7 @@ const isMe = (intId) => intId === Auth.userID;
export default {
isMe,
meetingName: () => Meetings.findOne({ meetingId: Auth.meetingID},
meetingName: () => Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { name: 1 } }).name,
users: () => Users.find({
meetingId: Auth.meetingID,
@ -32,8 +31,6 @@ export default {
{ fields: { groups: 1 } }).groups,
isBreakoutRecordable: () => Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { 'breakoutProps.record': 1 } }).breakoutProps.record,
createBreakoutRoom: (rooms, durationInMinutes, record = false, captureNotes = false, captureSlides = false, sendInviteToModerators = false) => makeCall('createBreakoutRoom', rooms, durationInMinutes, record, captureNotes, captureSlides, sendInviteToModerators),
sendInvitation: (breakoutId, userId) => makeCall('requestJoinURL', { breakoutId, userId }),
breakoutJoinedUsers: () => Breakouts.find({
joinedUsers: { $exists: true },
}, { fields: { joinedUsers: 1, breakoutId: 1, sequence: 1 }, sort: { sequence: 1 } }).fetch(),

View File

@ -4,9 +4,6 @@ import { defineMessages } from 'react-intl';
import Button from '/imports/ui/components/common/button/component';
import ModalSimple from '/imports/ui/components/common/modal/simple/component';
import { makeCall } from '/imports/ui/services/api';
import { Meteor } from 'meteor/meteor';
import Styled from './styles';
const propTypes = {
@ -31,8 +28,6 @@ const intlMessages = defineMessages({
},
});
const handleInactivityDismiss = () => makeCall('userActivitySign');
class ActivityCheck extends Component {
constructor(props) {
super(props);
@ -87,14 +82,14 @@ class ActivityCheck extends Component {
}
render() {
const { intl } = this.props;
const { intl, userActivitySign } = this.props;
const { responseDelay } = this.state;
return (
<ModalSimple
hideBorder
onRequestClose={handleInactivityDismiss}
onRequestClose={() => userActivitySign()}
shouldCloseOnOverlayClick={false}
shouldShowCloseButton={false}
priority="high"
@ -107,7 +102,7 @@ class ActivityCheck extends Component {
color="primary"
disabled={responseDelay <= 0}
label={intl.formatMessage(intlMessages.activityCheckButton)}
onClick={handleInactivityDismiss}
onClick={() => userActivitySign()}
role="button"
size="lg"
/>

View File

@ -1,7 +1,13 @@
import React from 'react';
import { injectIntl } from 'react-intl';
import { useMutation } from '@apollo/client';
import ActivityCheck from './component';
import { USER_SEND_ACTIVITY_SIGN } from './mutations';
const ActivityCheckContainer = (props) => <ActivityCheck {...props} />;
const ActivityCheckContainer = (props) => {
const [userActivitySign] = useMutation(USER_SEND_ACTIVITY_SIGN);
return <ActivityCheck userActivitySign={userActivitySign} {...props} />;
};
export default injectIntl(ActivityCheckContainer);

View File

@ -0,0 +1,9 @@
import { gql } from '@apollo/client';
export const USER_SEND_ACTIVITY_SIGN = gql`
mutation UserSendActivitySign {
userSendActivitySign
}
`;
export default { USER_SEND_ACTIVITY_SIGN };

View File

@ -47,7 +47,6 @@ import AudioService from '/imports/ui/components/audio/service';
import NotesContainer from '/imports/ui/components/notes/container';
import DEFAULT_VALUES from '../layout/defaultValues';
import AppService from '/imports/ui/components/app/service';
import TimerService from '/imports/ui/components/timer/service';
import TimeSync from './app-graphql/time-sync/component';
import PresentationUploaderToastContainer from '/imports/ui/components/presentation/presentation-toast/presentation-uploader-toast/container';
import BreakoutJoinConfirmationContainerGraphQL from '../breakout-join-confirmation/breakout-join-confirmation-graphql/component';
@ -148,7 +147,6 @@ class App extends Component {
presentationFitToWidth: false,
};
this.isTimerEnabled = TimerService.isEnabled();
this.timeOffsetInterval = null;
this.setPresentationFitToWidth = this.setPresentationFitToWidth.bind(this);
@ -222,12 +220,6 @@ class App extends Component {
if (deviceInfo.isMobile) setMobileUser(true);
if (this.isTimerEnabled) {
TimerService.fetchTimeOffset();
this.timeOffsetInterval = setInterval(TimerService.fetchTimeOffset,
TimerService.OFFSET_INTERVAL);
}
logger.info({ logCode: 'app_component_componentdidmount' }, 'Client loaded successfully');
}
@ -439,9 +431,7 @@ class App extends Component {
}
renderActivityCheck() {
const { User } = this.props;
const { inactivityWarningDisplay, inactivityWarningTimeoutSecs } = User;
const { inactivityWarningDisplay, inactivityWarningTimeoutSecs } = this.props;
return (inactivityWarningDisplay ? (
<ActivityCheckContainer

View File

@ -102,10 +102,14 @@ const AppContainer = (props) => {
isModerator: user.isModerator,
presenter: user.presenter,
speechLocale: user.speechLocale,
inactivityWarningDisplay: user.inactivityWarningDisplay,
inactivityWarningTimeoutSecs: user.inactivityWarningTimeoutSecs,
}));
const isModerator = currentUserData?.isModerator;
const isPresenter = currentUserData?.presenter;
const inactivityWarningDisplay = currentUserData?.inactivityWarningDisplay;
const inactivityWarningTimeoutSecs = currentUserData?.inactivityWarningTimeoutSecs;
const { sidebarContentPanel, isOpen: sidebarContentIsOpen } = sidebarContent;
const { sidebarNavPanel, isOpen: sidebarNavigationIsOpen } = sidebarNavigation;
@ -235,6 +239,8 @@ const AppContainer = (props) => {
setLocalSettings,
genericComponentId: genericComponent.genericComponentId,
audioCaptions: <AudioCaptionsLiveContainer speechLocale={currentUserData?.speechLocale} />,
inactivityWarningDisplay,
inactivityWarningTimeoutSecs,
}}
{...otherProps}
/>

View File

@ -7,7 +7,7 @@ import React, {
// @ts-ignore - it's has no types
import { diff } from '@mconf/bbb-diff';
import { useReactiveVar, useMutation } from '@apollo/client';
import { throttle } from 'radash';
import { throttle } from '/imports/utils/throttle';
import {
SpeechRecognitionAPI,
generateId,
@ -16,7 +16,6 @@ import {
isLocaleValid,
localeAsDefaultSelected,
setSpeechVoices,
updateFinalTranscript,
useFixedLocale,
} from './service';
import logger from '/imports/startup/client/logger';
@ -131,10 +130,17 @@ const AudioCaptionsSpeech: React.FC<AudioCaptionsSpeechProps> = ({
};
const throttledTranscriptUpdate = useMemo(() => throttle(
{ interval: THROTTLE_TIMEOUT },
captionSubmitText,
captionSubmitText, THROTTLE_TIMEOUT, {
leading: false,
trailing: true,
},
), []);
const updateFinalTranscript = (id: string, transcript: string, locale: string) => {
throttledTranscriptUpdate.cancel();
captionSubmitText(id, transcript, locale, true);
};
const onEnd = useCallback(() => {
stop();
}, []);

View File

@ -1,17 +1,12 @@
import { isAudioTranscriptionEnabled } from '../service';
import Auth from '/imports/ui/services/auth';
import deviceInfo from '/imports/utils/deviceInfo';
import { unique } from 'radash';
// @ts-ignore - bbb-diff is not typed
import { diff } from '@mconf/bbb-diff';
import { Session } from 'meteor/session';
import { throttle } from '/imports/utils/throttle';
import { makeCall } from '/imports/ui/services/api';
import { isAudioTranscriptionEnabled } from '../service';
const CONFIG = window.meetingClientSettings.public.app.audioCaptions;
const LANGUAGES = CONFIG.language.available;
const VALID_ENVIRONMENT = !deviceInfo.isMobile || CONFIG.mobile;
const THROTTLE_TIMEOUT = 2000;
// Reason: SpeechRecognition is not in window type definition
// Fix based on: https://stackoverflow.com/questions/41740683/speechrecognition-and-speechsynthesis-in-typescript
/* eslint @typescript-eslint/no-explicit-any: 0 */
@ -41,51 +36,6 @@ export const getLocale = () => {
return locale;
};
let prevId: string = '';
let prevTranscript: string = '';
const updateTranscript = (
id: string,
transcript: string,
locale: string,
isFinal: boolean,
) => {
// If it's a new sentence
if (id !== prevId) {
prevId = id;
prevTranscript = '';
}
const transcriptDiff = diff(prevTranscript, transcript);
let start = 0;
let end = 0;
let text = '';
if (transcriptDiff) {
start = transcriptDiff.start;
end = transcriptDiff.end;
text = transcriptDiff.text;
}
// Stores current transcript as previous
prevTranscript = transcript;
makeCall('updateTranscript', id, start, end, text, transcript, locale, isFinal);
};
const throttledTranscriptUpdate = throttle(updateTranscript, THROTTLE_TIMEOUT, {
leading: false,
trailing: true,
});
export const updateInterimTranscript = (id: string, transcript: string, locale: string) => {
throttledTranscriptUpdate(id, transcript, locale, false);
};
export const updateFinalTranscript = (id: string, transcript: string, locale: string) => {
throttledTranscriptUpdate.cancel();
updateTranscript(id, transcript, locale, true);
};
export const isLocaleValid = (locale: string) => LANGUAGES.includes(locale);
export default {

View File

@ -1,6 +1,5 @@
import { Meteor } from 'meteor/meteor';
import AudioService from '/imports/ui/components/audio/service';
import { makeCall } from '/imports/ui/services/api';
import AudioManager from '/imports/ui/services/audio-manager';
import VideoService from '/imports/ui/components/video-provider/service';
import { screenshareHasEnded } from '/imports/ui/components/screenshare/service';
@ -20,10 +19,6 @@ export const getIsConnected = () => {
return Meteor.status().connected;
};
export const endAllBreakouts = () => {
makeCall('endAllBreakouts');
};
export const forceExitAudio = () => {
AudioManager.forceExitAudio();
};
@ -59,7 +54,6 @@ export const rejoinAudio = () => {
export default {
getIsMicrophoneUser,
getIsReconnecting,
endAllBreakouts,
forceExitAudio,
stopVideo,
finishScreenShare,

View File

@ -1,252 +0,0 @@
import React, { Component } from 'react';
import { Session } from 'meteor/session';
import PropTypes from 'prop-types';
import SanitizeHTML from 'sanitize-html';
import Auth from '/imports/ui/services/auth';
import { setCustomLogoUrl, setModeratorOnlyMessage } from '/imports/ui/components/user-list/service';
import { makeCall } from '/imports/ui/services/api';
import logger from '/imports/startup/client/logger';
import LoadingScreen from '/imports/ui/components/common/loading-screen/component';
import Users from '/imports/api/users';
const propTypes = {
children: PropTypes.element.isRequired,
};
class JoinHandler extends Component {
static setError(codeError) {
if (codeError) Session.set('codeError', codeError);
}
constructor(props) {
super(props);
this.fetchToken = this.fetchToken.bind(this);
this.state = {
joined: false,
hasAlreadyJoined: false,
};
}
componentDidMount() {
this._isMounted = true;
if (!this.firstJoinTime) {
this.firstJoinTime = new Date();
}
Tracker.autorun((c) => {
const {
connected,
status,
} = Meteor.status();
const { hasAlreadyJoined } = this.state;
if (status === 'connecting' && !hasAlreadyJoined) {
this.setState({ joined: false });
}
logger.debug(`Initial connection status change. status: ${status}, connected: ${connected}`);
if (connected) {
const msToConnect = (new Date() - this.firstJoinTime) / 1000;
const secondsToConnect = parseFloat(msToConnect).toFixed(2);
logger.info({
logCode: 'joinhandler_component_initial_connection_time',
extraInfo: {
attemptForUserInfo: Auth.fullInfo,
timeToConnect: secondsToConnect,
},
}, `Connection to Meteor took ${secondsToConnect}s`);
this.firstJoinTime = undefined;
this.fetchToken();
} else if (status === 'failed') {
c.stop();
const msToConnect = (new Date() - this.firstJoinTime) / 1000;
const secondsToConnect = parseFloat(msToConnect).toFixed(2);
logger.info({
logCode: 'joinhandler_component_initial_connection_failed',
extraInfo: {
attemptForUserInfo: Auth.fullInfo,
timeToConnect: secondsToConnect,
},
}, `Connection to Meteor failed, took ${secondsToConnect}s`);
JoinHandler.setError('400');
Session.set('errorMessageDescription', 'Failed to connect to server');
this.firstJoinTime = undefined;
}
});
}
componentWillUnmount() {
this._isMounted = false;
}
async fetchToken() {
const { hasAlreadyJoined } = this.state;
const APP = window.meetingClientSettings.public.app;
if (!this._isMounted) return;
const urlParams = new URLSearchParams(window.location.search);
const sessionToken = urlParams.get('sessionToken');
if (!sessionToken) {
JoinHandler.setError('400');
Session.set('errorMessageDescription', 'Session token was not provided');
}
// Old credentials stored in memory were being used when joining a new meeting
if (!hasAlreadyJoined) {
Auth.clearCredentials();
}
const logUserInfo = () => {
const userInfo = window.navigator;
// Browser information is sent once on startup
// Sent here instead of Meteor.startup, as the
// user might not be validated by then, thus user's data
// would not be sent with this information
const clientInfo = {
language: userInfo.language,
userAgent: userInfo.userAgent,
screenSize: { width: window.screen.width, height: window.screen.height },
windowSize: { width: window.innerWidth, height: window.innerHeight },
bbbVersion: window.meetingClientSettings.public.app.bbbServerVersion,
location: window.location.href,
};
logger.info({
logCode: 'joinhandler_component_clientinfo',
extraInfo: { clientInfo },
},
'Log information about the client');
};
const setAuth = (resp) => {
const {
meetingID, internalUserID, authToken, logoutUrl,
fullname, externUserID, confname,
} = resp;
return new Promise((resolve) => {
Auth.set(
meetingID, internalUserID, authToken, logoutUrl,
sessionToken, fullname, externUserID, confname,
);
resolve(resp);
});
};
const setLogoutURL = (url) => {
Auth.logoutURL = url;
return true;
};
const setLogoURL = (resp) => {
setCustomLogoUrl(resp.customLogoURL);
return resp;
};
const setModOnlyMessage = (resp) => {
if (resp && resp.modOnlyMessage) {
const sanitizedModOnlyText = SanitizeHTML(resp.modOnlyMessage, {
allowedTags: ['a', 'b', 'br', 'i', 'img', 'li', 'small', 'span', 'strong', 'u', 'ul'],
allowedAttributes: {
a: ['href', 'name', 'target'],
img: ['src', 'width', 'height'],
},
allowedSchemes: ['https'],
});
setModeratorOnlyMessage(sanitizedModOnlyText);
}
return resp;
};
const setCustomData = (resp) => {
const { customdata } = resp;
return new Promise((resolve) => {
if (customdata.length) {
makeCall('addUserSettings', customdata).then((r) => resolve(r));
}
resolve(true);
});
};
const setBannerProps = (resp) => {
Session.set('bannerText', resp.bannerText);
Session.set('bannerColor', resp.bannerColor);
};
// use enter api to get params for the client
const url = `${APP.bbbWebBase}/api/enter?sessionToken=${sessionToken}`;
const fetchContent = await fetch(url, { credentials: 'include' });
const parseToJson = await fetchContent.json();
const { response } = parseToJson;
setLogoutURL(response.logoutUrl);
logUserInfo();
if (response.returncode !== 'FAILED') {
await setAuth(response);
setBannerProps(response);
setLogoURL(response);
setModOnlyMessage(response);
Tracker.autorun(async (cd) => {
const user = Users
.findOne({ userId: Auth.userID, approved: true }, { fields: { _id: 1 } });
if (user) {
await setCustomData(response);
cd.stop();
}
});
logger.info({
logCode: 'joinhandler_component_joinroutehandler_success',
extraInfo: {
response,
},
}, 'User successfully went through main.joinRouteHandler');
} else {
if (['missingSession', 'meetingForciblyEnded', 'notFound'].includes(response.messageKey)) {
JoinHandler.setError('410');
Session.set('errorMessageDescription', 'meeting_ended');
} else if (response.messageKey == "guestDeny") {
JoinHandler.setError('401');
Session.set('errorMessageDescription', 'guest_deny');
} else if (response.messageKey == "maxParticipantsReached") {
JoinHandler.setError('401');
Session.set('errorMessageDescription', 'max_participants_reason');
} else {
JoinHandler.setError('401');
Session.set('errorMessageDescription', response.message);
}
logger.error({
logCode: 'joinhandler_component_joinroutehandler_error',
extraInfo: {
response,
error: new Error(response.message),
},
}, 'User faced an error on main.joinRouteHandler.');
}
this.setState({
joined: true,
hasAlreadyJoined: true,
});
}
render() {
const { children } = this.props;
const { joined } = this.state;
return joined
? children
: (<LoadingScreen />);
}
}
export default JoinHandler;
JoinHandler.propTypes = propTypes;

View File

@ -1,4 +1,3 @@
import { makeCall } from '/imports/ui/services/api';
import Auth from '/imports/ui/services/auth';
import Settings from '/imports/ui/services/settings';
@ -22,8 +21,6 @@ const getParams = () => {
return params;
};
const createGroup = (externalId: string, model: string, name: string) => makeCall('createGroup', externalId, model, name);
const buildPadURL = (padId: string, sessionIds: Array<string>) => {
const params = getParams();
const sessionIdsStr = sessionIds.join(',');
@ -34,7 +31,6 @@ const buildPadURL = (padId: string, sessionIds: Array<string>) => {
};
export default {
createGroup,
buildPadURL,
getParams,
};

View File

@ -1,16 +1,10 @@
import { throttle } from 'radash';
import Pads from '/imports/api/pads';
import { makeCall } from '/imports/ui/services/api';
import Auth from '/imports/ui/services/auth';
import Settings from '/imports/ui/services/settings';
import {
screenshareHasEnded,
isScreenBroadcasting,
} from '/imports/ui/components/screenshare/service';
const PADS_CONFIG = window.meetingClientSettings.public.pads;
const THROTTLE_TIMEOUT = 2000;
const getLang = () => {
const { locale } = Settings.application;
return locale ? locale.toLowerCase() : '';
@ -27,14 +21,6 @@ const getParams = () => {
return params;
};
const getPadId = (externalId) => makeCall('getPadId', externalId);
const createGroup = (externalId, model, name) => makeCall('createGroup', externalId, model, name);
const createSession = (externalId) => makeCall('createSession', externalId);
const throttledCreateSession = throttle({ interval: THROTTLE_TIMEOUT }, createSession);
const pinPad = (externalId, pinned, stopWatching) => {
if (pinned) {
// Stop external video sharing if it's running.
@ -43,16 +29,11 @@ const pinPad = (externalId, pinned, stopWatching) => {
// Stop screen sharing if it's running.
if (isScreenBroadcasting()) screenshareHasEnded();
}
makeCall('pinPad', externalId, pinned);
};
const throttledPinPad = throttle({ interval: 1000 }, pinPad);
export default {
getPadId,
createGroup,
createSession: (externalId) => throttledCreateSession(externalId),
getParams,
pinPad: throttledPinPad,
};

View File

@ -1,7 +1,5 @@
import { Meteor } from 'meteor/meteor';
import Timer from '/imports/api/timer';
import Auth from '/imports/ui/services/auth';
import { makeCall } from '/imports/ui/services/api';
import { Session } from 'meteor/session';
import { ACTIONS, PANELS } from '../layout/enums';
@ -80,23 +78,6 @@ const isStopwatch = () => {
return false;
};
const timerEnded = () => makeCall('timerEnded');
const fetchTimeOffset = () => {
const t0 = Date.now();
makeCall('getServerTime').then((result) => {
if (result === 0) return;
const t3 = Date.now();
const ts = result;
const rtt = t3 - t0;
const timeOffset = Math.round(ts - rtt / 2 - t0);
Session.set('timeOffset', timeOffset);
});
};
const getTimeOffset = () => {
const timeOffset = Session.get('timeOffset');
@ -237,7 +218,6 @@ export default {
isRunning,
isStopwatch,
isAlarmEnabled,
fetchTimeOffset,
getTimeOffset,
getElapsedTime,
getInterval,
@ -247,5 +227,4 @@ export default {
getTimeAsString,
closePanel,
togglePanel,
timerEnded,
};

View File

@ -6,7 +6,6 @@ import Meetings from '/imports/api/meetings';
import Auth from '/imports/ui/services/auth';
import Storage from '/imports/ui/services/storage/session';
import { EMOJI_STATUSES } from '/imports/utils/statuses';
import { makeCall } from '/imports/ui/services/api';
import KEY_CODES from '/imports/utils/keyCodes';
import AudioService from '/imports/ui/components/audio/service';
import logger from '/imports/startup/client/logger';
@ -480,10 +479,6 @@ const roving = (...args) => {
}
};
const requestUserInformation = (userId) => {
makeCall('requestUserInformation', userId);
};
const sortUsersByFirstName = (a, b) => {
const aUser = { sortName: a.firstName ? a.firstName : '' };
const bUser = { sortName: b.firstName ? b.firstName : '' };
@ -612,7 +607,6 @@ export default {
hasBreakoutRoom,
getEmojiList: () => EMOJI_STATUSES,
getEmoji,
requestUserInformation,
focusFirstDropDownItem,
isUserPresenter,
getUsersProp,

View File

@ -7,7 +7,6 @@ import Users from '/imports/api/users';
import VideoStreams from '/imports/api/video-streams';
import UserListService from '/imports/ui/components/user-list/service';
import { meetingIsBreakout } from '/imports/ui/components/app/service';
import { makeCall } from '/imports/ui/services/api';
import { notify } from '/imports/ui/services/notification';
import deviceInfo from '/imports/utils/deviceInfo';
import browserInfo from '/imports/utils/browserInfo';
@ -229,14 +228,6 @@ class VideoService {
return devices;
}
sendUserShareWebcam(cameraId) {
makeCall('userShareWebcam', cameraId);
}
sendUserUnshareWebcam(cameraId) {
makeCall('userUnshareWebcam', cameraId);
}
getAuthenticatedURL() {
return Auth.authenticateURL(SFU_URL);
}

View File

@ -1,5 +1,3 @@
import { makeCall } from '/imports/ui/services/api';
export const privateMessageVisible = (id: string) => {
const privateInputSpace = document.getElementById(id);
if (privateInputSpace) {
@ -17,8 +15,6 @@ export const getNameInitials = (name: string) => {
return nameInitials.replace(/^\w/, (c: string) => c.toUpperCase());
};
export const setPrivateGuestLobbyMessage = (message: string, guestId: string) => makeCall('setPrivateGuestLobbyMessage', message, guestId);
export default {
privateMessageVisible,
getNameInitials,

View File

@ -1,40 +0,0 @@
import Auth from '/imports/ui/services/auth';
import { check } from 'meteor/check';
import logger from '/imports/startup/client/logger';
/**
* Send the request to the server via Meteor.call and don't treat errors.
*
* @param {string} name
* @param {any} args
* @see https://docs.meteor.com/api/methods.html#Meteor-call
* @return {Promise}
*/
export function makeCall(name, ...args) {
check(name, String);
// const { credentials } = Auth;
return new Promise(async (resolve, reject) => {
if (Meteor.status().connected) {
const result = await Meteor.callAsync(name, ...args);
// all tested cases it returned 0, empty array or undefined
resolve(result);
} else {
const failureString = `Call to ${name} failed because Meteor is not connected`;
// We don't want to send a log message if the call that failed was a log message.
// Without this you can get into an endless loop of failed logging.
if (name !== 'logClient') {
logger.warn({
logCode: 'servicesapiindex_makeCall',
extraInfo: {
attemptForUserInfo: Auth.fullInfo,
name,
...args,
},
}, failureString);
}
reject(failureString);
}
});
}