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
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
export default function userActivitySign() {
|
2019-02-22 05:09:44 +08:00
|
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
|
|
const EVENT_NAME = 'UserActivitySignCmdMsg';
|
2020-02-07 04:47:28 +08:00
|
|
|
const { meetingId, requesterUserId: userId } = extractCredentials(this.userId);
|
2021-03-17 00:15:41 +08:00
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
|
|
|
|
2019-02-22 05:09:44 +08:00
|
|
|
const payload = {
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
inactivityCheck: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
Users.update(selector, modifier); // TODO-- we should move this to a modifier
|
2019-02-22 05:09:44 +08:00
|
|
|
|
2019-02-27 01:40:01 +08:00
|
|
|
Logger.info(`User ${userId} sent a activity sign for meeting ${meetingId}`);
|
2019-02-22 05:09:44 +08:00
|
|
|
|
|
|
|
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload);
|
|
|
|
}
|