Add initial file structure for breakouts api

This commit is contained in:
Gabriel Carvalho de Campes 2016-10-27 15:47:40 -02:00
parent 9e86e95275
commit e8974fe929
7 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1 @@
export default new Mongo.Collection('breakouts');

View File

@ -0,0 +1,64 @@
import RedisPubSub from '/imports/startup/server/redis';
import Logger from '/imports/startup/server/logger';
// import handleChatMessage from './handlers/chatMessage';
// import handleChatHistory from './handlers/chatHistory';
import Breakouts from '/imports/api/breakouts';
RedisPubSub.on('CreateBreakoutRoomRequest', ({ payload }) => {
console.info('CreateBreakoutRoomRequest', payload);
const selector = {
breakoutMeetingId: payload.breakoutMeetingId,
};
const modifier = payload;
const cb = (err, numChanged) => {
if (err) {
return Logger.error(`Adding breakout to collection: ${err}`);
}
const { insertedId } = numChanged;
if (insertedId) {
return Logger.info(`Added breakout id=${payload.breakoutMeetingId}`);
}
return Logger.info(`Upserted breakout id=${payload.breakoutMeetingId}`);
};
Breakouts.upsert(selector, modifier, cb);
});
RedisPubSub.on('BreakoutRoomStarted', ({ payload }) => {
console.info('BreakoutRoomStarted', payload);
const selector = {
breakoutMeetingId: payload.meetingId,
};
modifier = {
$set: {
externalMeetingId: payload.externalMeetingId,
},
};
const cb = (err, numChanged) => {
if (err) {
return Logger.error(`Adding breakout to collection: ${err}`);
}
const { insertedId } = numChanged;
if (insertedId) {
return Logger.info(`Added breakout id=${payload.meetingId}`);
}
return Logger.info(`Upserted breakout id=${payload.meetingId}`);
};
Breakouts.upsert(selector, modifier, cb);
});
RedisPubSub.on('BreakoutRoomJoinURL', ({ payload }) => {
console.info('BreakoutRoomJoinURL', payload);
});

View File

@ -0,0 +1,3 @@
import './eventHandlers';
import './methods';
import './publishers';

View File

@ -0,0 +1,3 @@
import { Meteor } from 'meteor/meteor';
Meteor.methods({});

View File

@ -0,0 +1,12 @@
import Breakouts from '/imports/api/breakouts';
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('breakouts', credentials => {
Logger.info(credentials);
Breakouts.find({
parentMeetingId: credentials.meetingId,
});
});

View File

@ -7,6 +7,8 @@ import Cursor from '/imports/api/cursor';
import Captions from '/imports/api/captions';
import Polls from '/imports/api/polls';
import Breakouts from '/imports/api/breakouts';
function setCredentials(nextState, replace) {
if (nextState && nextState.params.authToken) {
const { meetingID, userID, authToken } = nextState.params;
@ -36,6 +38,8 @@ function subscribeForData() {
};
function subscribeFor(collectionName) {
window.Breakouts = Breakouts;
console.log('Subscribe 4Head');
const credentials = Auth.getCredentials();
return new Promise((resolve, reject) => {
Meteor.subscribe(collectionName, credentials, {

View File

@ -1,5 +1,6 @@
import '/imports/startup/server';
import '/imports/api/chat/server';
import '/imports/api/breakouts/server';
import '/imports/api/cursor/server/publications';
import '/imports/api/cursor/server/modifiers/clearCursorCollection';