2021-02-10 23:24:24 +08:00
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import { check } from 'meteor/check';
|
2021-10-16 03:07:13 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2021-05-05 01:34:31 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2021-02-10 23:24:24 +08:00
|
|
|
|
2021-10-16 03:07:13 +08:00
|
|
|
export default function createSession(externalId) {
|
2021-02-10 23:24:24 +08:00
|
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
2021-10-16 03:07:13 +08:00
|
|
|
const EVENT_NAME = 'PadCreateSessionReqMsg';
|
2021-02-10 23:24:24 +08:00
|
|
|
|
2021-05-05 01:34:31 +08:00
|
|
|
try {
|
2021-10-16 03:07:13 +08:00
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
|
|
|
|
2021-05-05 01:34:31 +08:00
|
|
|
check(meetingId, String);
|
2021-10-16 03:07:13 +08:00
|
|
|
check(requesterUserId, String);
|
|
|
|
check(externalId, String);
|
2021-02-10 23:24:24 +08:00
|
|
|
|
2021-05-05 01:34:31 +08:00
|
|
|
const payload = {
|
2021-10-16 03:07:13 +08:00
|
|
|
externalId,
|
2021-05-05 01:34:31 +08:00
|
|
|
};
|
2021-02-10 23:24:24 +08:00
|
|
|
|
2021-10-16 03:07:13 +08:00
|
|
|
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
2021-05-05 01:34:31 +08:00
|
|
|
} catch (err) {
|
2021-10-16 03:07:13 +08:00
|
|
|
Logger.error(`Exception while invoking method createSession ${err.stack}`);
|
2021-05-05 01:34:31 +08:00
|
|
|
}
|
2021-02-10 23:24:24 +08:00
|
|
|
}
|