bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/methods/changeAway.js
2023-06-07 22:10:07 -03:00

32 lines
977 B
JavaScript

import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import { extractCredentials } from '/imports/api/common/server/helpers';
import RedisPubSub from '/imports/startup/server/redis';
export default async function changeAway(away) {
try {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'ChangeUserAwayReqMsg';
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
check(away, Boolean);
const payload = {
userId: requesterUserId,
away,
};
Logger.verbose('Updated away status for user', {
meetingId, requesterUserId, away,
});
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
} catch (err) {
Logger.error(`Exception while invoking method changeAway ${err.stack}`);
}
}