bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/methods/userActivitySign.js
2023-03-20 16:35:52 -03:00

41 lines
1.2 KiB
JavaScript

import { Meteor } from 'meteor/meteor';
import Users from '/imports/api/users';
import RedisPubSub from '/imports/startup/server/redis';
import Logger from '/imports/startup/server/logger';
import { extractCredentials } from '/imports/api/common/server/helpers';
import { check } from 'meteor/check';
export default async function userActivitySign() {
try {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'UserActivitySignCmdMsg';
const { meetingId, requesterUserId: userId } = extractCredentials(this.userId);
check(meetingId, String);
check(userId, String);
const payload = {
userId,
};
const selector = {
userId,
};
const modifier = {
$set: {
inactivityCheck: false,
},
};
await Users.updateAsync(selector, modifier); // TODO-- we should move this to a modifier
Logger.info(`User ${userId} sent a activity sign for meeting ${meetingId}`);
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload);
} catch (err) {
Logger.error(`Exception while invoking method userActivitySign ${err.stack}`);
}
}