2019-02-22 05:09:44 +08:00
|
|
|
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';
|
2020-02-07 04:47:28 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2021-03-17 00:15:41 +08:00
|
|
|
import { check } from 'meteor/check';
|
2019-02-22 05:09:44 +08:00
|
|
|
|
2023-03-15 21:18:31 +08:00
|
|
|
export default async function userActivitySign() {
|
2021-05-06 00:47:43 +08:00
|
|
|
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);
|
2021-03-17 00:15:41 +08:00
|
|
|
|
2021-05-06 00:47:43 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
2021-03-17 00:15:41 +08:00
|
|
|
|
2021-05-06 00:47:43 +08:00
|
|
|
const payload = {
|
|
|
|
userId,
|
|
|
|
};
|
2019-02-22 05:09:44 +08:00
|
|
|
|
2021-05-06 00:47:43 +08:00
|
|
|
const selector = {
|
|
|
|
userId,
|
|
|
|
};
|
2019-02-22 05:09:44 +08:00
|
|
|
|
2021-05-06 00:47:43 +08:00
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
inactivityCheck: false,
|
|
|
|
},
|
|
|
|
};
|
2019-02-22 05:09:44 +08:00
|
|
|
|
2023-03-15 21:18:31 +08:00
|
|
|
await Users.updateAsync(selector, modifier); // TODO-- we should move this to a modifier
|
2019-02-22 05:09:44 +08:00
|
|
|
|
2021-05-06 00:47:43 +08:00
|
|
|
Logger.info(`User ${userId} sent a activity sign for meeting ${meetingId}`);
|
2019-02-22 05:09:44 +08:00
|
|
|
|
2021-05-06 00:47:43 +08:00
|
|
|
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload);
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Exception while invoking method userActivitySign ${err.stack}`);
|
|
|
|
}
|
2019-02-22 05:09:44 +08:00
|
|
|
}
|