Add try/catch on guest-users methods

This commit is contained in:
Joao Siebel 2021-05-05 09:26:21 -03:00
parent 169e5abe10
commit 1f9d6735a0
3 changed files with 40 additions and 28 deletions

View File

@ -9,12 +9,13 @@ const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'GuestsWaitingApprovedMsg'; const EVENT_NAME = 'GuestsWaitingApprovedMsg';
export default function allowPendingUsers(guests, status) { export default function allowPendingUsers(guests, status) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId); const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String); check(meetingId, String);
check(requesterUserId, String); check(requesterUserId, String);
check(guests, Array); check(guests, Array);
const mappedGuests = guests.map(guest => ({ status, guest: guest.intId })); const mappedGuests = guests.map((guest) => ({ status, guest: guest.intId }));
const payload = { const payload = {
approvedBy: requesterUserId, approvedBy: requesterUserId,
@ -23,5 +24,8 @@ export default function allowPendingUsers(guests, status) {
Logger.info(`User=${requesterUserId} ${status} guests ${JSON.stringify(mappedGuests)}`); Logger.info(`User=${requesterUserId} ${status} guests ${JSON.stringify(mappedGuests)}`);
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 allowPendingUsers ${err.stack}`);
}
} }

View File

@ -9,6 +9,7 @@ const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'SetGuestPolicyCmdMsg'; const EVENT_NAME = 'SetGuestPolicyCmdMsg';
export default function changeGuestPolicy(policyRule) { export default function changeGuestPolicy(policyRule) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId); const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String); check(meetingId, String);
@ -22,5 +23,8 @@ export default function changeGuestPolicy(policyRule) {
Logger.info(`User=${requesterUserId} change guest policy to ${policyRule}`); Logger.info(`User=${requesterUserId} change guest policy to ${policyRule}`);
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 changeGuestPolicy ${err.stack}`);
}
} }

View File

@ -9,6 +9,7 @@ const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'SetGuestLobbyMessageCmdMsg'; const EVENT_NAME = 'SetGuestLobbyMessageCmdMsg';
export default function setGuestLobbyMessage(message) { export default function setGuestLobbyMessage(message) {
try {
check(message, String); check(message, String);
const { meetingId, requesterUserId } = extractCredentials(this.userId); const { meetingId, requesterUserId } = extractCredentials(this.userId);
@ -20,5 +21,8 @@ export default function setGuestLobbyMessage(message) {
Logger.info(`User=${requesterUserId} set guest lobby message to ${message}`); Logger.info(`User=${requesterUserId} set guest lobby message to ${message}`);
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 setGuestLobbyMessage ${err.stack}`);
}
} }