From 9f39e119fdc1b6fd1621e3e6f002bbf836d75f52 Mon Sep 17 00:00:00 2001 From: Joao Siebel Date: Wed, 5 May 2021 11:34:36 -0300 Subject: [PATCH] Add try/catch on presentations methods --- .../server/methods/removePresentation.js | 25 ++++++++++------- .../server/methods/setPresentation.js | 26 +++++++++++------- .../methods/setPresentationDownloadable.js | 27 +++++++++++-------- 3 files changed, 47 insertions(+), 31 deletions(-) diff --git a/bigbluebutton-html5/imports/api/presentations/server/methods/removePresentation.js b/bigbluebutton-html5/imports/api/presentations/server/methods/removePresentation.js index 1bf2c92345..8a2ef1e898 100644 --- a/bigbluebutton-html5/imports/api/presentations/server/methods/removePresentation.js +++ b/bigbluebutton-html5/imports/api/presentations/server/methods/removePresentation.js @@ -1,23 +1,28 @@ import RedisPubSub from '/imports/startup/server/redis'; import { check } from 'meteor/check'; import { extractCredentials } from '/imports/api/common/server/helpers'; +import Logger from '/imports/startup/server/logger'; export default function removePresentation(presentationId, podId) { const REDIS_CONFIG = Meteor.settings.private.redis; const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; const EVENT_NAME = 'RemovePresentationPubMsg'; - const { meetingId, requesterUserId } = extractCredentials(this.userId); + try { + const { meetingId, requesterUserId } = extractCredentials(this.userId); - check(meetingId, String); - check(requesterUserId, String); - check(presentationId, String); - check(podId, String); + check(meetingId, String); + check(requesterUserId, String); + check(presentationId, String); + check(podId, String); - const payload = { - presentationId, - podId, - }; + const payload = { + presentationId, + podId, + }; - return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload); + RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload); + } catch (err) { + Logger.error(`Exception while invoking method removePresentation ${err.stack}`); + } } diff --git a/bigbluebutton-html5/imports/api/presentations/server/methods/setPresentation.js b/bigbluebutton-html5/imports/api/presentations/server/methods/setPresentation.js index 8d277b7f41..3ff16aee82 100644 --- a/bigbluebutton-html5/imports/api/presentations/server/methods/setPresentation.js +++ b/bigbluebutton-html5/imports/api/presentations/server/methods/setPresentation.js @@ -1,22 +1,28 @@ import RedisPubSub from '/imports/startup/server/redis'; import { check } from 'meteor/check'; import { extractCredentials } from '/imports/api/common/server/helpers'; +import Logger from '/imports/startup/server/logger'; export default function setPresentation(presentationId, podId) { const REDIS_CONFIG = Meteor.settings.private.redis; const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; const EVENT_NAME = 'SetCurrentPresentationPubMsg'; - const { meetingId, requesterUserId } = extractCredentials(this.userId); - check(meetingId, String); - check(requesterUserId, String); - check(presentationId, String); - check(podId, String); + try { + const { meetingId, requesterUserId } = extractCredentials(this.userId); - const payload = { - presentationId, - podId, - }; + check(meetingId, String); + check(requesterUserId, String); + check(presentationId, String); + check(podId, String); - return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload); + const payload = { + presentationId, + podId, + }; + + RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload); + } catch (err) { + Logger.error(`Exception while invoking method setPresentation ${err.stack}`); + } } diff --git a/bigbluebutton-html5/imports/api/presentations/server/methods/setPresentationDownloadable.js b/bigbluebutton-html5/imports/api/presentations/server/methods/setPresentationDownloadable.js index d8604fde26..2eb1abceef 100644 --- a/bigbluebutton-html5/imports/api/presentations/server/methods/setPresentationDownloadable.js +++ b/bigbluebutton-html5/imports/api/presentations/server/methods/setPresentationDownloadable.js @@ -1,24 +1,29 @@ import RedisPubSub from '/imports/startup/server/redis'; import { check } from 'meteor/check'; import { extractCredentials } from '/imports/api/common/server/helpers'; +import Logger from '/imports/startup/server/logger'; export default function setPresentationDownloadable(presentationId, downloadable) { const REDIS_CONFIG = Meteor.settings.private.redis; const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; const EVENT_NAME = 'SetPresentationDownloadablePubMsg'; - const { meetingId, requesterUserId } = extractCredentials(this.userId); + try { + const { meetingId, requesterUserId } = extractCredentials(this.userId); - check(meetingId, String); - check(requesterUserId, String); - check(downloadable, Boolean); - check(presentationId, String); + check(meetingId, String); + check(requesterUserId, String); + check(downloadable, Boolean); + check(presentationId, String); - const payload = { - presentationId, - podId: 'DEFAULT_PRESENTATION_POD', - downloadable, - }; + const payload = { + presentationId, + podId: 'DEFAULT_PRESENTATION_POD', + downloadable, + }; - return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload); + RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload); + } catch (err) { + Logger.error(`Exception while invoking method setPresentationDownloadable ${err.stack}`); + } }