2019-11-20 01:49:18 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2021-02-08 20:55:38 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2023-04-07 04:43:57 +08:00
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
2019-11-20 01:49:18 +08:00
|
|
|
|
2023-04-07 04:43:57 +08:00
|
|
|
export default async function setMobileUser() {
|
2021-05-06 00:47:43 +08:00
|
|
|
try {
|
2023-04-07 04:43:57 +08:00
|
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
|
|
const EVENT_NAME = 'ChangeUserMobileFlagReqMsg';
|
|
|
|
|
2021-05-06 00:47:43 +08:00
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
2019-11-20 01:49:18 +08:00
|
|
|
|
2021-05-06 00:47:43 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
2019-11-20 01:49:18 +08:00
|
|
|
|
2023-04-07 04:43:57 +08:00
|
|
|
const payload = {
|
|
|
|
userId: requesterUserId,
|
|
|
|
mobile: true,
|
|
|
|
};
|
|
|
|
|
2021-05-06 00:47:43 +08:00
|
|
|
Logger.verbose(`Mobile user ${requesterUserId} from meeting ${meetingId}`);
|
2019-11-20 01:49:18 +08:00
|
|
|
|
2023-04-07 04:43:57 +08:00
|
|
|
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
2021-05-06 00:47:43 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Exception while invoking method setMobileUser ${err.stack}`);
|
|
|
|
}
|
2019-11-20 01:49:18 +08:00
|
|
|
}
|