2021-03-05 06:26:25 +08:00
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import { getUsers } from '/imports/api/whiteboard-multi-user/server/helpers';
|
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2021-05-06 02:53:13 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2021-03-05 06:26:25 +08:00
|
|
|
|
2023-04-01 04:40:41 +08:00
|
|
|
export default async function addGlobalAccess(whiteboardId) {
|
2021-05-06 02:53:13 +08:00
|
|
|
try {
|
|
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
|
|
const EVENT_NAME = 'ModifyWhiteboardAccessPubMsg';
|
2021-03-05 06:26:25 +08:00
|
|
|
|
2021-05-06 02:53:13 +08:00
|
|
|
check(whiteboardId, String);
|
2021-03-05 06:26:25 +08:00
|
|
|
|
2021-05-06 02:53:13 +08:00
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
2021-03-05 06:26:25 +08:00
|
|
|
|
2021-05-06 02:53:13 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
2021-03-05 06:26:25 +08:00
|
|
|
|
2023-04-01 04:40:41 +08:00
|
|
|
const multiUser = await getUsers(meetingId);
|
2021-03-05 06:26:25 +08:00
|
|
|
|
2021-05-06 02:53:13 +08:00
|
|
|
const payload = {
|
|
|
|
multiUser,
|
|
|
|
whiteboardId,
|
|
|
|
};
|
2021-03-05 06:26:25 +08:00
|
|
|
|
2021-05-06 02:53:13 +08:00
|
|
|
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Exception while invoking method addGlobalAccess ${err.stack}`);
|
|
|
|
}
|
2021-03-05 06:26:25 +08:00
|
|
|
}
|