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,19 +9,23 @@ const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'GuestsWaitingApprovedMsg';
export default function allowPendingUsers(guests, status) {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
check(guests, Array);
const mappedGuests = guests.map(guest => ({ status, guest: guest.intId }));
check(meetingId, String);
check(requesterUserId, String);
check(guests, Array);
const mappedGuests = guests.map((guest) => ({ status, guest: guest.intId }));
const payload = {
approvedBy: requesterUserId,
guests: mappedGuests,
};
const payload = {
approvedBy: requesterUserId,
guests: mappedGuests,
};
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,18 +9,22 @@ const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'SetGuestPolicyCmdMsg';
export default function changeGuestPolicy(policyRule) {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
check(policyRule, String);
check(meetingId, String);
check(requesterUserId, String);
check(policyRule, String);
const payload = {
setBy: requesterUserId,
policy: policyRule,
};
const payload = {
setBy: requesterUserId,
policy: 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,16 +9,20 @@ const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'SetGuestLobbyMessageCmdMsg';
export default function setGuestLobbyMessage(message) {
check(message, String);
try {
check(message, String);
const { meetingId, requesterUserId } = extractCredentials(this.userId);
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
check(meetingId, String);
check(requesterUserId, String);
const payload = { message };
const payload = { 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}`);
}
}