Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Abhinav Kumar <[email protected]>
  • Loading branch information
abhinavkrin committed Nov 6, 2024
1 parent 9ef4a43 commit bf1704e
Showing 1 changed file with 36 additions and 22 deletions.
58 changes: 36 additions & 22 deletions src/videoConfProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import { URL } from 'url';

import { HttpStatusCode } from '@rocket.chat/apps-engine/definition/accessors';
import type { IVideoConferenceUser } from '@rocket.chat/apps-engine/definition/videoConferences';
import type {
Expand All @@ -8,10 +10,24 @@ import type {
VideoConfDataExtended,
} from '@rocket.chat/apps-engine/definition/videoConfProviders';
import { XMLParser } from 'fast-xml-parser';
import { URL } from 'url';

import type { BigBlueButtonApp } from './BigBlueButtonApp';
import { AppSetting, settings } from './settings';
import { AppSetting } from './settings';

type CreateUrlParams = {
name: string;
meetingID: string;
attendeePW: string;
moderatorPW: string;
welcome?: string;
meta_html5chat: boolean;
meta_html5navbar: boolean;
meta_html5autoswaplayout: boolean;
meta_html5autosharewebcam: boolean;
meta_html5hidepresentation: boolean;
guestPolicy?: 'ALWAYS_ACCEPT' | 'ALWAYS_DENY' | 'ASK_MODERATOR';
logoutURL?: string;
};

const methodsWithoutChecksum = ['setConfigXML', '/', 'enter', 'configXML', 'signOut'];
const apiParams: Record<string, [string | RegExp, boolean][]> = {
Expand All @@ -32,7 +48,7 @@ const apiParams: Record<string, [string | RegExp, boolean][]> = {
['moderatorOnlyMessage', false],
['autoStartRecording', false],
['allowStartStopRecording', false],
['guestPolicy',false],
['guestPolicy', false],
[/meta_\w+/, false],
],
'join': [
Expand Down Expand Up @@ -168,11 +184,11 @@ export class BBBProvider implements IVideoConfProvider {

const meetingID = call._id;
const settings = this.app.getAccessors().environmentReader.getSettings();
var guestPolicy = await settings.getValueById(AppSetting.GuestPolicy);
let guestPolicy = await settings.getValueById(AppSetting.GuestPolicy);
const welcomeMsg = await settings.getValueById(AppSetting.WelcomeMsg);
var logoutURL = await settings.getValueById(AppSetting.LogoutURL);
var createUrlParams = {
const logoutURL = await settings.getValueById(AppSetting.LogoutURL);

const createUrlParams: CreateUrlParams = {
name: call.title || 'Rocket.Chat',
meetingID,
attendeePW: 'rocket.chat.attendee',
Expand All @@ -188,34 +204,32 @@ export class BBBProvider implements IVideoConfProvider {
meta_html5autosharewebcam: false,
// eslint-disable-next-line @typescript-eslint/camelcase
meta_html5hidepresentation: true,
}
};

// validate guestPolicy
var guestPolicyAcceptable: Array<string> = ['ALWAYS_ACCEPT', 'ALWAYS_DENY', 'ASK_MODERATOR'];
const guestPolicyAcceptable: Array<string> = ['ALWAYS_ACCEPT', 'ALWAYS_DENY', 'ASK_MODERATOR'];
if (guestPolicy !== null && guestPolicy !== '') {
guestPolicy = guestPolicy.toUpperCase();

if (!(guestPolicyAcceptable.includes(guestPolicy))) {
throw new Error('BBB guestPolicy settings has bad value : '+guestPolicy);
}
else {
createUrlParams['guestPolicy'] = guestPolicy

if (!guestPolicyAcceptable.includes(guestPolicy)) {
throw new Error(`BBB guestPolicy settings has bad value : ${guestPolicy}`);
} else {
createUrlParams.guestPolicy = guestPolicy;
}
}

// validate logoutURL
if (logoutURL !== null && logoutURL !== '') {
try {
const validateLogoutUrl = new URL(logoutURL);
if(!(validateLogoutUrl.protocol === 'http:') && !(validateLogoutUrl.protocol === 'https:')) {
throw new Error('BBB logoutURL settings is not a valid url : '+logoutURL);
if (!(validateLogoutUrl.protocol === 'http:') && !(validateLogoutUrl.protocol === 'https:')) {
throw new Error(`BBB logoutURL settings is not a valid url : ${logoutURL}`);
} else {
createUrlParams.logoutURL = logoutURL;
}
else {
createUrlParams['logoutURL'] = logoutURL
}
} catch (err) {
throw new Error('BBB logoutURL settings has bad value : '+logoutURL+' - error : '+err.message);
}
throw new Error(`BBB logoutURL settings has bad value : ${logoutURL} - error : ${err.message}`);
}
}

const createUrl = this.getUrlFor('create', createUrlParams);
Expand Down

0 comments on commit bf1704e

Please sign in to comment.