Add try/catch on presentations methods

This commit is contained in:
Joao Siebel 2021-05-05 11:34:36 -03:00
parent e7647ec4ae
commit 9f39e119fd
3 changed files with 47 additions and 31 deletions

View File

@ -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}`);
}
}

View File

@ -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}`);
}
}

View File

@ -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}`);
}
}