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