Refactor publishers and method kickUser to the new pattern
This commit is contained in:
parent
b069eed00d
commit
9c2b42e99a
@ -0,0 +1,4 @@
|
||||
import RedisPubSub from '/imports/startup/server/redis';
|
||||
// import handleSlideResize from './handlers/slideResize';
|
||||
|
||||
// RedisPubSub.on('presentation_page_resized_message', handleSlideResize);
|
@ -0,0 +1,16 @@
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import { check } from 'meteor/check';
|
||||
import changeCurrentSlide from '../modifiers/changeCurrentSlide';
|
||||
|
||||
export default function handleSlideChange({ payload }) {
|
||||
const meetingId = payload.meeting_id;
|
||||
const slide = payload.page;
|
||||
|
||||
check(meetingId, String);
|
||||
check(slide, Object);
|
||||
|
||||
const slideId = slide.id;
|
||||
const presentationId = slideId.split('/')[0];
|
||||
|
||||
return changeCurrentSlide(meetingId, presentationId, slideId);
|
||||
};
|
@ -0,0 +1,17 @@
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import Slides from '/imports/api/slides';
|
||||
import { check } from 'meteor/check';
|
||||
import resizeSlide from '../modifiers/resizeSlide';
|
||||
|
||||
export default function handleSlideResize({ payload }) {
|
||||
const meetingId = payload.meeting_id;
|
||||
const slide = payload.page;
|
||||
|
||||
check(meetingId, String);
|
||||
check(slide, Object);
|
||||
|
||||
const slideId = slide.id;
|
||||
const presentationId = slideId.split('/')[0];
|
||||
|
||||
return resizeSlide(meetingId, presentationId, slideId, slide);
|
||||
};
|
3
bigbluebutton-html5/imports/api/users/server/index.js
Normal file
3
bigbluebutton-html5/imports/api/users/server/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
import './eventHandlers';
|
||||
import './methods';
|
||||
import './publishers';
|
6
bigbluebutton-html5/imports/api/users/server/methods.js
Normal file
6
bigbluebutton-html5/imports/api/users/server/methods.js
Normal file
@ -0,0 +1,6 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import kickUser from './methods/kickUser';
|
||||
|
||||
Meteor.methods({
|
||||
kickUser,
|
||||
});
|
@ -1,25 +1,30 @@
|
||||
import { check } from 'meteor/check';
|
||||
import RedisPubSub from '/imports/startup/server/redis';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import { isAllowedTo } from '/imports/startup/server/userPermissions';
|
||||
import { appendMessageHeader, publish } from '/imports/api/common/server/helpers';
|
||||
|
||||
Meteor.methods({
|
||||
//meetingId: the meeting where the user is
|
||||
//toKickUserId: the userid of the user to kick
|
||||
//requesterUserId: the userid of the user that wants to kick
|
||||
//authToken: the authToken of the user that wants to kick
|
||||
kickUser(credentials, toKickUserId) {
|
||||
const REDIS_CONFIG = Meteor.settings.redis;
|
||||
const { meetingId, requesterUserId, requesterToken } = credentials;
|
||||
let message;
|
||||
if (isAllowedTo('kickUser', credentials)) {
|
||||
message = {
|
||||
payload: {
|
||||
userid: toKickUserId,
|
||||
ejected_by: requesterUserId,
|
||||
meeting_id: meetingId,
|
||||
},
|
||||
};
|
||||
message = appendMessageHeader('eject_user_from_meeting_request_message', message);
|
||||
return publish(REDIS_CONFIG.channels.toBBBApps.users, message);
|
||||
}
|
||||
},
|
||||
});
|
||||
export default function kickUser(credentials, userId) {
|
||||
const REDIS_CONFIG = Meteor.settings.redis;
|
||||
const CHANNEL = REDIS_CONFIG.channels.toBBBApps.users;
|
||||
const EVENT_NAME = 'eject_user_from_meeting_request_message';
|
||||
|
||||
if (!isAllowedTo('kickUser', credentials)) {
|
||||
throw new Meteor.Error('not-allowed', `You are not allowed to kickUser`);
|
||||
}
|
||||
|
||||
const { meetingId, requesterUserId } = credentials;
|
||||
|
||||
check(meetingId, String);
|
||||
check(requesterUserId, String);
|
||||
check(userId, String);
|
||||
|
||||
let payload = {
|
||||
userid: userId,
|
||||
ejected_by: requesterUserId,
|
||||
meeting_id: meetingId,
|
||||
};
|
||||
|
||||
Logger.verbose(`User '${userId}' was kicked by '${requesterUserId}' from meeting '${meetingId}'`);
|
||||
|
||||
return RedisPubSub.publish(CHANNEL, EVENT_NAME, payload);
|
||||
};
|
||||
|
44
bigbluebutton-html5/imports/api/users/server/publishers.js
Normal file
44
bigbluebutton-html5/imports/api/users/server/publishers.js
Normal file
@ -0,0 +1,44 @@
|
||||
import Users from '/imports/api/Users';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { check } from 'meteor/check';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import { isAllowedTo } from '/imports/startup/server/userPermissions';
|
||||
|
||||
Meteor.publish('Users', function (credentials) {
|
||||
// TODO: Some publishers have ACL and others dont
|
||||
// if (!isAllowedTo('@@@', credentials)) {
|
||||
// this.error(new Meteor.Error(402, "The user was not authorized to subscribe for 'Users'"));
|
||||
// }
|
||||
|
||||
const { meetingId, requesterUserId, requesterToken } = credentials;
|
||||
|
||||
check(meetingId, String);
|
||||
check(requesterUserId, String);
|
||||
check(requesterToken, String);
|
||||
|
||||
// TODO:
|
||||
// - Add reconnection handlers
|
||||
// - Add validateAuthToken stuff
|
||||
// - Update `connection_status` when the user disconnects
|
||||
|
||||
this.onStop(() => {
|
||||
// update connection_status info to offline
|
||||
});
|
||||
|
||||
const selector = {
|
||||
meetingId,
|
||||
'user.connection_status': {
|
||||
$in: ['online', ''],
|
||||
},
|
||||
};
|
||||
|
||||
const options = {
|
||||
fields: {
|
||||
authToken: false,
|
||||
},
|
||||
};
|
||||
|
||||
Logger.info(`Publishing Users for ${meetingId} ${requesterUserId} ${requesterToken}`);
|
||||
|
||||
return Users.find(selector, options);
|
||||
});
|
@ -27,8 +27,7 @@ import '/imports/api/captions/server/publications';
|
||||
import '/imports/api/captions/server/modifiers/clearCaptionsCollection';
|
||||
import '/imports/api/captions/server/modifiers/eventHandlers';
|
||||
|
||||
import '/imports/api/users/server/publications';
|
||||
import '/imports/api/users/server/methods/kickUser';
|
||||
import '/imports/api/users/server';
|
||||
import '/imports/api/users/server/methods/listenOnlyRequestToggle';
|
||||
import '/imports/api/users/server/methods/muteUser';
|
||||
import '/imports/api/users/server/methods/setUserPresenter';
|
||||
|
Loading…
Reference in New Issue
Block a user