Merge pull request #17388 from Scroody/meteor-migration

refactor: Migration of the API to async for Meteor 3.0
This commit is contained in:
Anton Georgiev 2023-04-12 10:09:38 -04:00 committed by GitHub
commit defd372a40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
315 changed files with 1285 additions and 1090 deletions

View File

@ -1,7 +1,7 @@
import { check } from 'meteor/check';
import _ from "lodash";
import _ from 'lodash';
export default function addAnnotation(meetingId, whiteboardId, userId, annotation, Annotations) {
async function addAnnotation(meetingId, whiteboardId, userId, annotation, Annotations) {
check(meetingId, String);
check(whiteboardId, String);
check(annotation, Object);
@ -17,9 +17,9 @@ export default function addAnnotation(meetingId, whiteboardId, userId, annotatio
id,
};
const oldAnnotation = Annotations.findOne(selector);
const oldAnnotation = await Annotations.findOneAsync(selector);
if (oldAnnotation) {
annotationInfo = _.merge(oldAnnotation.annotationInfo, annotationInfo)
annotationInfo = _.merge(oldAnnotation.annotationInfo, annotationInfo);
}
const modifier = {
@ -34,3 +34,5 @@ export default function addAnnotation(meetingId, whiteboardId, userId, annotatio
return { selector, modifier };
}
export default addAnnotation;

View File

@ -16,8 +16,8 @@ if (Meteor.isServer) {
// 6. meetingId, whiteboardId, userId ( 1 )
// These 2 indexes seem to cover all of the cases
Annotations._ensureIndex({ id: 1 });
Annotations._ensureIndex({ meetingId: 1, whiteboardId: 1, userId: 1 });
Annotations.createIndexAsync({ id: 1 });
Annotations.createIndexAsync({ meetingId: 1, whiteboardId: 1, userId: 1 });
}
export default Annotations;

View File

@ -1,10 +1,9 @@
import _ from 'lodash';
import { check } from 'meteor/check';
import modifyWhiteboardAccess from '/imports/api/whiteboard-multi-user/server/modifiers/modifyWhiteboardAccess';
import clearAnnotations from '../modifiers/clearAnnotations';
import addAnnotation from '../modifiers/addAnnotation';
export default function handleWhiteboardAnnotations({ header, body }, meetingId) {
async function handleWhiteboardAnnotations({ header, body }, meetingId) {
check(header, Object);
if (header.userId !== 'nodeJSapp') { return false; }
@ -17,12 +16,15 @@ export default function handleWhiteboardAnnotations({ header, body }, meetingId)
check(whiteboardId, String);
check(multiUser, Array);
clearAnnotations(meetingId, whiteboardId);
_.each(annotations, (annotation) => {
await clearAnnotations(meetingId, whiteboardId);
// we use a for loop here instead of a map because we need to guarantee the order of the annotations.
for (const annotation of annotations) {
const { wbId, userId } = annotation;
addAnnotation(meetingId, wbId, userId, annotation);
});
await addAnnotation(meetingId, wbId, userId, annotation);
}
modifyWhiteboardAccess(meetingId, whiteboardId, multiUser);
await modifyWhiteboardAccess(meetingId, whiteboardId, multiUser);
return true;
}
export default handleWhiteboardAnnotations;

View File

@ -3,7 +3,7 @@ import AnnotationsStreamer from '/imports/api/annotations/server/streamer';
import clearAnnotations from '../modifiers/clearAnnotations';
export default function handleWhiteboardCleared({ body }, meetingId) {
export default async function handleWhiteboardCleared({ body }, meetingId) {
check(body, {
userId: String,
whiteboardId: String,
@ -14,9 +14,11 @@ export default function handleWhiteboardCleared({ body }, meetingId) {
if (fullClear) {
AnnotationsStreamer(meetingId).emit('removed', { meetingId, whiteboardId });
return clearAnnotations(meetingId, whiteboardId);
const result = await clearAnnotations(meetingId, whiteboardId);
return result;
}
AnnotationsStreamer(meetingId).emit('removed', { meetingId, whiteboardId, userId });
return clearAnnotations(meetingId, whiteboardId, userId);
const result = await clearAnnotations(meetingId, whiteboardId, userId);
return result;
}

View File

@ -3,16 +3,16 @@ import { check } from 'meteor/check';
import AnnotationsStreamer from '/imports/api/annotations/server/streamer';
import removeAnnotation from '../modifiers/removeAnnotation';
export default function handleWhiteboardDelete({ body }, meetingId) {
const whiteboardId = body.whiteboardId;
export default async function handleWhiteboardDelete({ body }, meetingId) {
const { whiteboardId } = body;
const shapesIds = body.annotationsIds;
check(whiteboardId, String);
check(shapesIds, Array);
//console.log("!!!!!!!!!!!! handleWhiteboardDelete !!!!!!!!!!!!!!!!!",shapesIds)
shapesIds.map(shapeId => {
const result = await Promise.all(shapesIds.map(async (shapeId) => {
AnnotationsStreamer(meetingId).emit('removed', { meetingId, whiteboardId, shapeId });
removeAnnotation(meetingId, whiteboardId, shapeId);
})
await removeAnnotation(meetingId, whiteboardId, shapeId);
}));
return result;
}

View File

@ -29,7 +29,7 @@ const process = () => {
Meteor.setTimeout(process, ANNOTATION_PROCESS_INTERVAL);
};
export default function handleWhiteboardSend({ envelope, header, body }, meetingId) {
export default async function handleWhiteboardSend({ envelope, header, body }, meetingId) {
const userId = header.userId;
const whiteboardId = body.whiteboardId;
const annotations = body.annotations;
@ -43,13 +43,14 @@ export default function handleWhiteboardSend({ envelope, header, body }, meeting
if (!annotationsQueue.hasOwnProperty(meetingId)) {
annotationsQueue[meetingId] = [];
}
annotations.forEach(annotation => {
// we use a for loop here instead of a map because we need to guarantee the order of the annotations.
for (const annotation of annotations) {
annotationsQueue[meetingId].push({ meetingId, whiteboardId, userId: annotation.userId, annotation });
if (instanceIdFromMessage === myInstanceId) {
addAnnotation(meetingId, whiteboardId, annotation.userId, annotation);
await addAnnotation(meetingId, whiteboardId, annotation.userId, annotation);
}
})
}
if (queueMetrics) {
Metrics.setAnnotationQueueLength(meetingId, annotationsQueue[meetingId].length);
}

View File

@ -3,13 +3,14 @@ import { check } from 'meteor/check';
import AnnotationsStreamer from '/imports/api/annotations/server/streamer';
import removeAnnotation from '../modifiers/removeAnnotation';
export default function handleWhiteboardUndo({ body }, meetingId) {
const whiteboardId = body.whiteboardId;
export default async function handleWhiteboardUndo({ body }, meetingId) {
const { whiteboardId } = body;
const shapeId = body.annotationId;
check(whiteboardId, String);
check(shapeId, String);
AnnotationsStreamer(meetingId).emit('removed', { meetingId, whiteboardId, shapeId });
return removeAnnotation(meetingId, whiteboardId, shapeId);
const result = await removeAnnotation(meetingId, whiteboardId, shapeId);
return result;
}

View File

@ -3,15 +3,15 @@ import Logger from '/imports/startup/server/logger';
import Annotations from '/imports/api/annotations';
import addAnnotationQuery from '/imports/api/annotations/addAnnotation';
export default function addAnnotation(meetingId, whiteboardId, userId, annotation) {
export default async function addAnnotation(meetingId, whiteboardId, userId, annotation) {
check(meetingId, String);
check(whiteboardId, String);
check(annotation, Object);
const query = addAnnotationQuery(meetingId, whiteboardId, userId, annotation, Annotations);
const query = await addAnnotationQuery(meetingId, whiteboardId, userId, annotation, Annotations);
try {
const { insertedId } = Annotations.upsert(query.selector, query.modifier);
const { insertedId } = await Annotations.upsertAsync(query.selector, query.modifier);
if (insertedId) {
Logger.info(`Added annotation id=${annotation.id} whiteboard=${whiteboardId}`);

View File

@ -1,7 +1,7 @@
import Annotations from '/imports/api/annotations';
import Logger from '/imports/startup/server/logger';
export default function clearAnnotations(meetingId, whiteboardId, userId) {
export default async function clearAnnotations(meetingId, whiteboardId, userId) {
const selector = {};
if (meetingId) {
@ -17,7 +17,7 @@ export default function clearAnnotations(meetingId, whiteboardId, userId) {
}
try {
const numberAffected = Annotations.remove(selector);
const numberAffected = await Annotations.removeAsync(selector);
if (numberAffected) {
if (userId) {

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import Annotations from '/imports/api/annotations';
import Logger from '/imports/startup/server/logger';
export default function removeAnnotation(meetingId, whiteboardId, shapeId) {
export default async function removeAnnotation(meetingId, whiteboardId, shapeId) {
check(meetingId, String);
check(whiteboardId, String);
check(shapeId, String);
@ -14,7 +14,7 @@ export default function removeAnnotation(meetingId, whiteboardId, shapeId) {
};
try {
const numberAffected = Annotations.remove(selector);
const numberAffected = await Annotations.removeAsync(selector);
if (numberAffected) {
Logger.info(`Removed annotation id=${shapeId} whiteboard=${whiteboardId}`);

View File

@ -3,7 +3,7 @@ import { Meteor } from 'meteor/meteor';
const AudioCaptions = new Mongo.Collection('audio-captions');
if (Meteor.isServer) {
AudioCaptions._ensureIndex({ meetingId: 1 });
AudioCaptions.createIndexAsync({ meetingId: 1 });
}
export default AudioCaptions;

View File

@ -1,6 +1,6 @@
import setTranscript from '/imports/api/audio-captions/server/modifiers/setTranscript';
export default function transcriptUpdated({ header, body }) {
export default async function transcriptUpdated({ header, body }) {
const { meetingId } = header;
const {
@ -8,5 +8,5 @@ export default function transcriptUpdated({ header, body }) {
transcript,
} = body;
setTranscript(meetingId, transcriptId, transcript);
await setTranscript(meetingId, transcriptId, transcript);
}

View File

@ -1,10 +1,10 @@
import AudioCaptions from '/imports/api/audio-captions';
import Logger from '/imports/startup/server/logger';
export default function clearAudioCaptions(meetingId) {
export default async function clearAudioCaptions(meetingId) {
if (meetingId) {
try {
const numberAffected = AudioCaptions.remove({ meetingId });
const numberAffected = await AudioCaptions.removeAsync({ meetingId });
if (numberAffected) {
Logger.info(`Cleared AudioCaptions (${meetingId})`);
@ -14,7 +14,7 @@ export default function clearAudioCaptions(meetingId) {
}
} else {
try {
const numberAffected = AudioCaptions.remove({});
const numberAffected = await AudioCaptions.removeAsync({});
if (numberAffected) {
Logger.info('Cleared AudioCaptions (all)');

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import AudioCaptions from '/imports/api/audio-captions';
import Logger from '/imports/startup/server/logger';
export default function setTranscript(meetingId, transcriptId, transcript) {
export default async function setTranscript(meetingId, transcriptId, transcript) {
try {
check(meetingId, String);
check(transcriptId, String);
@ -17,7 +17,7 @@ export default function setTranscript(meetingId, transcriptId, transcript) {
},
};
const numberAffected = AudioCaptions.upsert(selector, modifier);
const numberAffected = await AudioCaptions.upsertAsync(selector, modifier);
if (numberAffected) {
Logger.debug(`Set transcriptId=${transcriptId} transcript=${transcript} meeting=${meetingId}`);

View File

@ -3,8 +3,9 @@ import { Meteor } from 'meteor/meteor';
import Logger from '/imports/startup/server/logger';
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
function audioCaptions() {
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
async function audioCaptions() {
const tokenValidation = await AuthTokenValidation
.findOneAsync({ connectionId: this.connection.id });
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
Logger.warn(`Publishing AudioCaptions was requested by unauth connection ${this.connection.id}`);

View File

@ -7,7 +7,7 @@ const collectionOptions = Meteor.isClient ? {
const AuthTokenValidation = new Mongo.Collection('auth-token-validation', collectionOptions);
if (Meteor.isServer) {
AuthTokenValidation._ensureIndex({ connectionId: 1 });
AuthTokenValidation.createIndexAsync({ connectionId: 1 });
}
export const ValidationStates = Object.freeze({

View File

@ -2,15 +2,14 @@ import AuthTokenValidation from '/imports/api/auth-token-validation';
import Logger from '/imports/startup/server/logger';
import ClientConnections from '/imports/startup/server/ClientConnections';
export default function clearAuthTokenValidation(meetingId) {
return AuthTokenValidation.remove({ meetingId }, (err, num) => {
if (err) {
Logger.info(`Error when removing auth-token-validation for meeting=${meetingId}`);
}
export default async function clearAuthTokenValidation(meetingId) {
try {
await AuthTokenValidation.removeAsync({ meetingId });
if (!process.env.BBB_HTML5_ROLE || process.env.BBB_HTML5_ROLE === 'frontend') {
ClientConnections.removeMeeting(meetingId);
}
Logger.info(`Cleared AuthTokenValidation (${meetingId})`);
});
} catch (error) {
Logger.info(`Error when removing auth-token-validation for meeting=${meetingId}`);
}
}

View File

@ -1,16 +1,14 @@
import Logger from '/imports/startup/server/logger';
import AuthTokenValidation from '/imports/api/auth-token-validation';
export default function removeValidationState(meetingId, userId, connectionId) {
export default async function removeValidationState(meetingId, userId, connectionId) {
const selector = {
meetingId, userId, connectionId,
};
const cb = (err) => {
if (err) {
Logger.error(`Could not remove from collection AuthTokenValidation: ${err}`);
try {
await AuthTokenValidation.removeAsync(selector);
} catch (error) {
Logger.error(`Could not remove from collection AuthTokenValidation: ${error}`);
}
};
return AuthTokenValidation.remove(selector, cb);
}

View File

@ -1,7 +1,13 @@
import Logger from '/imports/startup/server/logger';
import AuthTokenValidation from '/imports/api/auth-token-validation';
export default function upsertValidationState(meetingId, userId, validationStatus, connectionId, reason = null) {
export default async function upsertValidationState(
meetingId,
userId,
validationStatus,
connectionId,
reason = null,
) {
const selector = {
meetingId, userId, connectionId,
};
@ -17,8 +23,9 @@ export default function upsertValidationState(meetingId, userId, validationStatu
};
try {
AuthTokenValidation.remove({ meetingId, userId, connectionId: { $ne: connectionId } });
const { numberAffected } = AuthTokenValidation.upsert(selector, modifier);
await AuthTokenValidation
.removeAsync({ meetingId, userId, connectionId: { $ne: connectionId } });
const { numberAffected } = AuthTokenValidation.upsertAsync(selector, modifier);
if (numberAffected) {
Logger.info(`Upserted ${JSON.stringify(selector)} ${validationStatus} in AuthTokenValidation`);

View File

@ -7,7 +7,7 @@ const collectionOptions = Meteor.isClient ? {
const BreakoutsHistory = new Mongo.Collection('breakouts-history', collectionOptions);
if (Meteor.isServer) {
BreakoutsHistory._ensureIndex({ meetingId: 1 });
BreakoutsHistory.createIndexAsync({ meetingId: 1 });
}
export default BreakoutsHistory;

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import BreakoutsHistory from '/imports/api/breakouts-history';
import Logger from '/imports/startup/server/logger';
export default function handleBreakoutRoomsList({ body }) {
export default async function handleBreakoutRoomsList({ body }) {
const {
meetingId,
rooms,
@ -22,7 +22,7 @@ export default function handleBreakoutRoomsList({ body }) {
};
try {
const { insertedId } = BreakoutsHistory.upsert(selector, modifier);
const { insertedId } = await BreakoutsHistory.upsertAsync(selector, modifier);
if (insertedId) {
Logger.info(`Added rooms to breakout-history Data: meeting=${meetingId}`);

View File

@ -2,8 +2,7 @@ import Logger from '/imports/startup/server/logger';
import { check } from 'meteor/check';
import BreakoutsHistory from '/imports/api/breakouts-history';
export default function handleSendMessageToAllBreakoutRoomsEvtMsg({ body }, meetingId) {
export default async function handleSendMessageToAllBreakoutRoomsEvtMsg({ body }, meetingId) {
const {
senderId,
msg,
@ -30,7 +29,7 @@ export default function handleSendMessageToAllBreakoutRoomsEvtMsg({ body }, meet
};
try {
const { insertedId } = BreakoutsHistory.upsert(selector, modifier);
const { insertedId } = await BreakoutsHistory.upsertAsync(selector, modifier);
if (insertedId) {
Logger.info(`Added broadCastMsg to breakout-history Data: meeting=${meetingId}`);

View File

@ -9,8 +9,9 @@ import { publicationSafeGuard } from '/imports/api/common/server/helpers';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
function breakoutsHistory() {
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
async function breakoutsHistory() {
const tokenValidation = await AuthTokenValidation
.findOneAsync({ connectionId: this.connection.id });
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
Logger.warn(`Publishing Meetings-history was requested by unauth connection ${this.connection.id}`);
@ -20,7 +21,7 @@ function breakoutsHistory() {
const { meetingId, userId } = tokenValidation;
Logger.debug('Publishing Breakouts-History', { meetingId, userId });
const User = Users.findOne({ userId, meetingId }, { fields: { userId: 1, role: 1 } });
const User = await Users.findOneAsync({ userId, meetingId }, { fields: { userId: 1, role: 1 } });
if (!User || User.role !== ROLE_MODERATOR) {
return BreakoutsHistory.find({ meetingId: '' });
}
@ -32,8 +33,9 @@ function breakoutsHistory() {
};
// Monitor this publication and stop it when user is not a moderator anymore
const comparisonFunc = () => {
const user = Users.findOne({ userId, meetingId }, { fields: { role: 1, userId: 1 } });
const comparisonFunc = async () => {
const user = await Users
.findOneAsync({ userId, meetingId }, { fields: { role: 1, userId: 1 } });
const condition = user.role === ROLE_MODERATOR;
if (!condition) {

View File

@ -11,8 +11,8 @@ if (Meteor.isServer) {
// 1. breakoutId ( handleJoinUrl, roomStarted, clearBreakouts )
// 2. parentMeetingId ( updateTimeRemaining )
Breakouts._ensureIndex({ breakoutId: 1 });
Breakouts._ensureIndex({ parentMeetingId: 1 });
Breakouts.createIndexAsync({ breakoutId: 1 });
Breakouts.createIndexAsync({ parentMeetingId: 1 });
}
export default Breakouts;

View File

@ -1,9 +1,9 @@
import { check } from 'meteor/check';
import clearBreakouts from '../modifiers/clearBreakouts';
export default function handleBreakoutClosed({ body }) {
export default async function handleBreakoutClosed({ body }) {
const { breakoutId } = body;
check(breakoutId, String);
return clearBreakouts(breakoutId);
const result = await clearBreakouts(breakoutId);
return result;
}

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import Breakouts from '/imports/api/breakouts';
export default function handleBreakoutJoinURL({ body }) {
export default async function handleBreakoutJoinURL({ body }) {
const {
redirectToHtml5JoinURL,
userId,
@ -28,24 +28,19 @@ export default function handleBreakoutJoinURL({ body }) {
const ATTEMPT_EVERY_MS = 1000;
let numberAffected = 0;
const updateBreakout = async () => {
numberAffected = await Breakouts.updateAsync(selector, modifier);
};
const updateBreakout = Meteor.bindEnvironment(() => {
numberAffected = Breakouts.update(selector, modifier);
});
const updateBreakoutPromise = new Promise((resolve) => {
const updateBreakoutInterval = setInterval(() => {
updateBreakout();
await new Promise((resolve) => {
const updateBreakoutInterval = setInterval(async () => {
await updateBreakout();
if (numberAffected) {
resolve(clearInterval(updateBreakoutInterval));
}
}, ATTEMPT_EVERY_MS);
});
updateBreakoutPromise.then(() => {
Logger.info(`Upserted breakout id=${breakoutId}`);
});
} catch (err) {
Logger.error(`Adding breakout to collection: ${err}`);
}

View File

@ -4,7 +4,7 @@ import { check } from 'meteor/check';
import flat from 'flat';
import handleBreakoutRoomsListHist from '/imports/api/breakouts-history/server/handlers/breakoutRoomsList';
export default function handleBreakoutRoomsList({ body }, meetingId) {
export default async function handleBreakoutRoomsList({ body }, meetingId) {
// 0 seconds default breakout time, forces use of real expiration time
const DEFAULT_TIME_REMAINING = 0;
@ -14,7 +14,7 @@ export default function handleBreakoutRoomsList({ body }, meetingId) {
} = body;
// set firstly the last seq, then client will know when receive all
rooms.sort((a, b) => ((a.sequence < b.sequence) ? 1 : -1)).forEach((breakout) => {
await rooms.sort((a, b) => ((a.sequence < b.sequence) ? 1 : -1)).forEach(async (breakout) => {
const { breakoutId, html5JoinUrls, ...breakoutWithoutUrls } = breakout;
check(meetingId, String);
@ -43,18 +43,13 @@ export default function handleBreakoutRoomsList({ body }, meetingId) {
...urls,
},
};
try {
const { numberAffected } = Breakouts.upsert(selector, modifier);
const numberAffected = await Breakouts.upsertAsync(selector, modifier);
if (numberAffected) {
Logger.info('Updated timeRemaining and externalMeetingId '
+ `for breakout id=${breakoutId}`);
} else {
Logger.error(`updating breakout: ${numberAffected}`);
}
} catch (err) {
Logger.error(`updating breakout: ${err}`);
}
});
handleBreakoutRoomsListHist({ body });
});
}

View File

@ -4,7 +4,7 @@ import Logger from '/imports/startup/server/logger';
import { check } from 'meteor/check';
import { lowercaseTrim } from '/imports/utils/string-utils';
export default function joinedUsersChanged({ body }) {
export default async function joinedUsersChanged({ body }) {
check(body, Object);
const {
@ -22,7 +22,8 @@ export default function joinedUsersChanged({ body }) {
breakoutId,
};
const usersMapped = users.map(user => ({ userId: user.id, name: user.name, sortName: lowercaseTrim(user.name) }));
const usersMapped = users
.map((user) => ({ userId: user.id, name: user.name, sortName: lowercaseTrim(user.name) }));
const modifier = {
$set: {
joinedUsers: usersMapped,
@ -30,14 +31,23 @@ export default function joinedUsersChanged({ body }) {
};
try {
const numberAffected = Breakouts.update(selector, modifier);
const numberAffected = await Breakouts.updateAsync(selector, modifier);
if (numberAffected) {
updateUserBreakoutRoom(parentId, breakoutId, users);
await updateUserBreakoutRoom(parentId, breakoutId, users);
Logger.info(`Updated joined users in breakout id=${breakoutId}`);
}
} catch (err) {
Logger.error(`updating joined users in breakout: ${err}`);
}
// .then((res) => {
// if (res.numberAffected) {
// updateUserBreakoutRoom(parentId, breakoutId, users);
// Logger.info(`Updated joined users in breakout id=${breakoutId}`);
// }
// }).catch((err) => {
// Logger.error(`updating joined users in breakout: ${err}`);
// });
}

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import Breakouts from '/imports/api/breakouts';
export default function handleUpdateTimeRemaining({ body }, meetingId) {
export default async function handleUpdateTimeRemaining({ body }, meetingId) {
const {
timeRemaining,
} = body;
@ -23,14 +23,11 @@ export default function handleUpdateTimeRemaining({ body }, meetingId) {
const options = {
multi: true,
};
try {
const numberAffected = Breakouts.update(selector, modifier, options);
const numberAffected = Breakouts.updateAsync(selector, modifier, options);
if (numberAffected) {
Logger.info(`Updated breakout time remaining for breakouts where parentMeetingId=${meetingId}`);
}
} catch (err) {
Logger.error(`Updating breakouts: ${err}`);
} else {
Logger.error(`Updating breakouts: ${numberAffected}`);
}
}

View File

@ -2,7 +2,7 @@ import Breakouts from '/imports/api/breakouts';
import Logger from '/imports/startup/server/logger';
import { check } from 'meteor/check';
export default function userBreakoutChanged({ body }) {
export default async function userBreakoutChanged({ body }) {
check(body, Object);
const {
@ -49,11 +49,11 @@ export default function userBreakoutChanged({ body }) {
let numberAffectedRows = 0;
if (oldBreakoutSelector.breakoutId !== '') {
numberAffectedRows += Breakouts.update(oldBreakoutSelector, oldModifier);
numberAffectedRows += await Breakouts.updateAsync(oldBreakoutSelector, oldModifier);
}
if (newBreakoutSelector.breakoutId !== '') {
numberAffectedRows += Breakouts.update(newBreakoutSelector, newModifier);
numberAffectedRows += await Breakouts.updateAsync(newBreakoutSelector, newModifier);
}
if (numberAffectedRows > 0) {

View File

@ -1,14 +1,14 @@
import Logger from '/imports/startup/server/logger';
import Breakouts from '/imports/api/breakouts';
export default function clearBreakouts(breakoutId) {
export default async function clearBreakouts(breakoutId) {
if (breakoutId) {
const selector = {
breakoutId,
};
try {
const numberAffected = Breakouts.remove(selector);
const numberAffected = await Breakouts.removeAsync(selector);
if (numberAffected) {
Logger.info(`Cleared Breakouts (${breakoutId})`);
@ -18,7 +18,7 @@ export default function clearBreakouts(breakoutId) {
}
} else {
try {
const numberAffected = Breakouts.remove({});
const numberAffected = await Breakouts.removeAsync({});
if (numberAffected) {
Logger.info('Cleared Breakouts (all)');
}

View File

@ -7,8 +7,9 @@ import { publicationSafeGuard } from '/imports/api/common/server/helpers';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
function breakouts() {
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
async function breakouts() {
const tokenValidation = await AuthTokenValidation
.findOneAsync({ connectionId: this.connection.id });
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
Logger.warn(`Publishing Breakouts was requested by unauth connection ${this.connection.id}`);
@ -16,7 +17,7 @@ function breakouts() {
}
const { meetingId, userId } = tokenValidation;
const User = Users.findOne({ userId, meetingId }, { fields: { role: 1 } });
const User = await Users.findOneAsync({ userId, meetingId }, { fields: { role: 1 } });
Logger.debug('Publishing Breakouts', { meetingId, userId });
const fields = {
@ -45,8 +46,8 @@ function breakouts() {
],
};
// Monitor this publication and stop it when user is not a moderator anymore
const comparisonFunc = () => {
const user = Users.findOne({ userId, meetingId }, { fields: { role: 1, userId: 1 } });
const comparisonFunc = async () => {
const user = await Users.findOneAsync({ userId, meetingId }, { fields: { role: 1, userId: 1 } });
const condition = user.role === ROLE_MODERATOR;
if (!condition) {

View File

@ -7,7 +7,7 @@ const collectionOptions = Meteor.isClient ? {
const Captions = new Mongo.Collection('captions', collectionOptions);
if (Meteor.isServer) {
Captions._ensureIndex({ meetingId: 1, locale: 1 });
Captions.createIndexAsync({ meetingId: 1, locale: 1 });
}
export default Captions;

View File

@ -1,11 +1,11 @@
import updateCaptionsOwner from '/imports/api/captions/server/modifiers/updateCaptionsOwner';
export default function captionsOwnerUpdated({ header, body }) {
export default async function captionsOwnerUpdated({ header, body }) {
const { meetingId } = header;
const {
locale,
ownerId,
} = body;
updateCaptionsOwner(meetingId, locale, ownerId);
await updateCaptionsOwner(meetingId, locale, ownerId);
}

View File

@ -14,12 +14,15 @@ const init = (meetingId) => {
method: 'get',
url: LOCALES_URL,
responseType: 'json',
}).then((response) => {
}).then(async (response) => {
const { status } = response;
if (status !== 200) return;
const locales = response.data;
locales.forEach((locale) => createCaptions(meetingId, locale.locale, locale.name));
await Promise.all(locales.map(async (locale) => {
const caption = await createCaptions(meetingId, locale.locale, locale.name);
return caption;
}));
}).catch((error) => Logger.error(`Could not create captions for ${meetingId}: ${error}`));
};

View File

@ -5,7 +5,7 @@ import Logger from '/imports/startup/server/logger';
import setTranscript from '/imports/api/captions/server/modifiers/setTranscript';
import updatePad from '/imports/api/pads/server/methods/updatePad';
export default function pushSpeechTranscript(locale, transcript, type) {
export default async function pushSpeechTranscript(locale, transcript, type) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
@ -15,7 +15,7 @@ export default function pushSpeechTranscript(locale, transcript, type) {
check(transcript, String);
check(type, String);
const captions = Captions.findOne({
const captions = await Captions.findOneAsync({
meetingId,
ownerId: requesterUserId,
locale,
@ -28,7 +28,7 @@ export default function pushSpeechTranscript(locale, transcript, type) {
updatePad(meetingId, requesterUserId, locale, text);
}
setTranscript(meetingId, locale, transcript);
await setTranscript(meetingId, locale, transcript);
}
} catch (err) {
Logger.error(`Exception while invoking method pushSpeechTranscript ${err.stack}`);

View File

@ -4,7 +4,7 @@ import { extractCredentials } from '/imports/api/common/server/helpers';
import Logger from '/imports/startup/server/logger';
import setDictation from '/imports/api/captions/server/modifiers/setDictation';
export default function startDictation(locale) {
export default async function startDictation(locale) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
@ -12,13 +12,13 @@ export default function startDictation(locale) {
check(requesterUserId, String);
check(locale, String);
const captions = Captions.findOne({
const captions = await Captions.findOneAsync({
meetingId,
ownerId: requesterUserId,
locale,
});
if (captions) setDictation(meetingId, locale, true);
if (captions) await setDictation(meetingId, locale, true);
} catch (err) {
Logger.error(`Exception while invoking method startDictation ${err.stack}`);
}

View File

@ -4,7 +4,7 @@ import { extractCredentials } from '/imports/api/common/server/helpers';
import Logger from '/imports/startup/server/logger';
import setDictation from '/imports/api/captions/server/modifiers/setDictation';
export default function stopDictation(locale) {
export default async function stopDictation(locale) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
@ -12,13 +12,13 @@ export default function stopDictation(locale) {
check(requesterUserId, String);
check(locale, String);
const captions = Captions.findOne({
const captions = await Captions.findOne({
meetingId,
ownerId: requesterUserId,
locale,
});
if (captions) setDictation(meetingId, locale, false);
if (captions) await setDictation(meetingId, locale, false);
} catch (err) {
Logger.error(`Exception while invoking method stopDictation ${err.stack}`);
}

View File

@ -1,10 +1,10 @@
import Captions from '/imports/api/captions';
import Logger from '/imports/startup/server/logger';
export default function clearCaptions(meetingId) {
export default async function clearCaptions(meetingId) {
if (meetingId) {
try {
const numberAffected = Captions.remove({ meetingId });
const numberAffected = await Captions.removeAsync({ meetingId });
if (numberAffected) {
Logger.info(`Cleared Captions (${meetingId})`);
@ -14,7 +14,7 @@ export default function clearCaptions(meetingId) {
}
} else {
try {
const numberAffected = Captions.remove({});
const numberAffected = await Captions.removeAsync({});
if (numberAffected) {
Logger.info('Cleared Captions (all)');

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import Captions from '/imports/api/captions';
import Logger from '/imports/startup/server/logger';
export default function createCaptions(meetingId, locale, name) {
export default async function createCaptions(meetingId, locale, name) {
try {
check(meetingId, String);
check(locale, String);
@ -22,7 +22,7 @@ export default function createCaptions(meetingId, locale, name) {
transcript: '',
};
const numberAffected = Captions.upsert(selector, modifier);
const { numberAffected } = await Captions.upsertAsync(selector, modifier);
if (numberAffected) {
Logger.verbose(`Created captions=${locale} meeting=${meetingId}`);

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import Captions from '/imports/api/captions';
import Logger from '/imports/startup/server/logger';
export default function setDictation(meetingId, locale, dictating) {
export default async function setDictation(meetingId, locale, dictating) {
try {
check(meetingId, String);
check(locale, String);
@ -20,7 +20,7 @@ export default function setDictation(meetingId, locale, dictating) {
},
};
const numberAffected = Captions.upsert(selector, modifier);
const { numberAffected } = Captions.upsertAsync(selector, modifier);
if (numberAffected) {
Logger.info(`Set captions=${locale} dictating=${dictating} meeting=${meetingId}`);

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import Captions from '/imports/api/captions';
import Logger from '/imports/startup/server/logger';
export default function setTranscript(meetingId, locale, transcript) {
export default async function setTranscript(meetingId, locale, transcript) {
try {
check(meetingId, String);
check(locale, String);
@ -19,7 +19,7 @@ export default function setTranscript(meetingId, locale, transcript) {
},
};
const numberAffected = Captions.upsert(selector, modifier);
const numberAffected = await Captions.upsertAsync(selector, modifier);
if (numberAffected) {
Logger.debug(`Set captions=${locale} transcript=${transcript} meeting=${meetingId}`);

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import Captions from '/imports/api/captions';
import Logger from '/imports/startup/server/logger';
export default function updateCaptionsOwner(meetingId, locale, ownerId) {
export default async function updateCaptionsOwner(meetingId, locale, ownerId) {
try {
check(meetingId, String);
check(locale, String);
@ -20,7 +20,7 @@ export default function updateCaptionsOwner(meetingId, locale, ownerId) {
},
};
const numberAffected = Captions.upsert(selector, modifier);
const numberAffected = await Captions.upsert(selector, modifier);
if (numberAffected) {
Logger.info(`Added captions=${locale} owner=${ownerId} meeting=${meetingId}`);

View File

@ -3,8 +3,9 @@ import { Meteor } from 'meteor/meteor';
import Logger from '/imports/startup/server/logger';
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
function captions() {
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
async function captions() {
const tokenValidation = await AuthTokenValidation
.findOneAsync({ connectionId: this.connection.id });
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
Logger.warn(`Publishing Captions was requested by unauth connection ${this.connection.id}`);

View File

@ -22,7 +22,7 @@ export const indexOf = [].indexOf || function (item) {
return -1;
};
export const processForHTML5ServerOnly = (fn) => (message, ...args) => {
export const processForHTML5ServerOnly = (fn) => async (message, ...args) => {
const { envelope } = message;
const { routing } = envelope;
const { msgType, meetingId, userId } = routing;
@ -32,7 +32,7 @@ export const processForHTML5ServerOnly = (fn) => (message, ...args) => {
meetingId,
};
const user = Users.findOne(selector);
const user = await Users.findOneAsync(selector);
const shouldSkip = user && msgType === MSG_DIRECT_TYPE && userId !== NODE_USER && user.clientType !== 'HTML5';
if (shouldSkip) return () => { };
@ -51,9 +51,10 @@ export const extractCredentials = (credentials) => {
// The provided function is publication-specific and must check the "survival condition" of the publication.
export const publicationSafeGuard = function (fn, self) {
let stopped = false;
const periodicCheck = function () {
const periodicCheck = async function () {
if (stopped) return;
if (!fn()) {
const result = await fn();
if (!result) {
self.added(self._name, 'publication-stop-marker', { id: 'publication-stop-marker', stopped: true });
self.stop();
} else Meteor.setTimeout(periodicCheck, 1000);

View File

@ -7,7 +7,7 @@ const collectionOptions = Meteor.isClient ? {
const ConnectionStatus = new Mongo.Collection('connection-status', collectionOptions);
if (Meteor.isServer) {
ConnectionStatus._ensureIndex({ meetingId: 1, userId: 1 });
ConnectionStatus.createIndexAsync({ meetingId: 1, userId: 1 });
}
export default ConnectionStatus;

View File

@ -1,7 +1,7 @@
import ConnectionStatus from '/imports/api/connection-status';
import Logger from '/imports/startup/server/logger';
export default function clearConnectionStatus(meetingId) {
export default async function clearConnectionStatus(meetingId) {
const selector = {};
if (meetingId) {
@ -9,7 +9,7 @@ export default function clearConnectionStatus(meetingId) {
}
try {
const numberAffected = ConnectionStatus.remove(selector);
const numberAffected = await ConnectionStatus.removeAsync(selector);
if (numberAffected) {
if (meetingId) {

View File

@ -7,7 +7,7 @@ const STATS = Meteor.settings.public.stats;
const STATS_INTERVAL = STATS.interval;
const STATS_CRITICAL_RTT = STATS.rtt[STATS.rtt.length - 1];
export default function updateConnectionStatus(meetingId, userId, status) {
export default async function updateConnectionStatus(meetingId, userId, status) {
check(meetingId, String);
check(userId, String);
@ -32,14 +32,15 @@ export default function updateConnectionStatus(meetingId, userId, status) {
}
try {
const { numberAffected } = ConnectionStatus.upsert(selector, { $set: modifier });
const { numberAffected } = await ConnectionStatus.upsertAsync(selector, { $set: modifier });
if (numberAffected && status !== 'normal') {
changeHasConnectionStatus(true, userId, meetingId);
await changeHasConnectionStatus(true, userId, meetingId);
Logger.verbose(`Updated connection status meetingId=${meetingId} userId=${userId} status=${status}`);
}
Meteor.setTimeout(() => {
const connectionLossTimeThreshold = new Date().getTime() - (STATS_INTERVAL + STATS_CRITICAL_RTT);
Meteor.setTimeout(async () => {
const connectionLossTimeThreshold = new Date()
.getTime() - (STATS_INTERVAL + STATS_CRITICAL_RTT);
const selectorNotResponding = {
meetingId,
@ -48,15 +49,15 @@ export default function updateConnectionStatus(meetingId, userId, status) {
clientNotResponding: false,
};
const numberAffectedNotResponding = ConnectionStatus.update(selectorNotResponding, {
$set: { clientNotResponding: true }
const numberAffectedNotResponding = await ConnectionStatus
.updateAsync(selectorNotResponding, {
$set: { clientNotResponding: true },
});
if (numberAffectedNotResponding) {
Logger.info(`Updated clientNotResponding=true meetingId=${meetingId} userId=${userId}`);
}
}, STATS_INTERVAL + STATS_CRITICAL_RTT);
} catch (err) {
Logger.error(`Updating connection status meetingId=${meetingId} userId=${userId}: ${err}`);
}

View File

@ -8,8 +8,9 @@ import { publicationSafeGuard } from '/imports/api/common/server/helpers';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
function connectionStatus() {
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
async function connectionStatus() {
const tokenValidation = await AuthTokenValidation
.findOneAsync({ connectionId: this.connection.id });
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
Logger.warn(`Publishing ConnectionStatus was requested by unauth connection ${this.connection.id}`);
@ -27,15 +28,16 @@ function connectionStatus() {
status: 1,
statusUpdatedAt: 1,
clientNotResponding: 1,
}
};
const User = Users.findOne({ userId, meetingId }, { fields: { role: 1 } });
const User = await Users.findOneAsync({ userId, meetingId }, { fields: { role: 1 } });
Logger.info(`Publishing connection status for ${meetingId} ${userId}`);
if (!!User && User.role === ROLE_MODERATOR) {
// Monitor this publication and stop it when user is not a moderator anymore
const comparisonFunc = () => {
const user = Users.findOne({ userId, meetingId }, { fields: { role: 1, userId: 1 } });
const comparisonFunc = async () => {
const user = await Users
.findOneAsync({ userId, meetingId }, { fields: { role: 1, userId: 1 } });
const condition = user.role === ROLE_MODERATOR;
if (!condition) {
@ -46,10 +48,10 @@ function connectionStatus() {
return condition;
};
publicationSafeGuard(comparisonFunc, this);
return ConnectionStatus.find({ meetingId }, { fields: fields });
return ConnectionStatus.find({ meetingId }, { fields });
}
return ConnectionStatus.find({ meetingId, userId }, { fields: fields });
return ConnectionStatus.find({ meetingId, userId }, { fields });
}
function publish(...args) {

View File

@ -1,7 +1,7 @@
import { check } from 'meteor/check';
import startExternalVideo from '../modifiers/startExternalVideo';
export default function handleStartExternalVideo({ header, body }, meetingId) {
export default async function handleStartExternalVideo({ header, body }, meetingId) {
check(header, Object);
check(body, Object);
check(meetingId, String);
@ -9,5 +9,5 @@ export default function handleStartExternalVideo({ header, body }, meetingId) {
const { userId } = header;
const { externalVideoUrl } = body;
startExternalVideo(meetingId, userId, externalVideoUrl);
await startExternalVideo(meetingId, userId, externalVideoUrl);
}

View File

@ -1,11 +1,11 @@
import { check } from 'meteor/check';
import stopExternalVideo from '../modifiers/stopExternalVideo';
export default function handleStopExternalVideo({ header }, meetingId) {
export default async function handleStopExternalVideo({ header }, meetingId) {
check(header, Object);
check(meetingId, String);
const { userId } = header;
stopExternalVideo(userId, meetingId);
await stopExternalVideo(userId, meetingId);
}

View File

@ -1,7 +1,7 @@
import { check } from 'meteor/check';
import updateExternalVideo from '../modifiers/updateExternalVideo';
export default function handleUpdateExternalVideo({ header, body }, meetingId) {
export default async function handleUpdateExternalVideo({ header, body }, meetingId) {
check(header, Object);
check(body, Object);
check(meetingId, String);
@ -15,5 +15,5 @@ export default function handleUpdateExternalVideo({ header, body }, meetingId) {
state,
} = body;
updateExternalVideo(meetingId, userId, status, rate, time, state);
await updateExternalVideo(meetingId, userId, status, rate, time, state);
}

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import { ExternalVideoMeetings } from '/imports/api/meetings';
export default function startExternalVideo(meetingId, userId, externalVideoUrl) {
export default async function startExternalVideo(meetingId, userId, externalVideoUrl) {
try {
check(meetingId, String);
check(userId, String);
@ -12,7 +12,7 @@ export default function startExternalVideo(meetingId, userId, externalVideoUrl)
const modifier = { $set: { externalVideoUrl } };
Logger.info(`User id=${userId} sharing an external video: ${externalVideoUrl} for meeting ${meetingId}`);
ExternalVideoMeetings.update(selector, modifier);
await ExternalVideoMeetings.updateAsync(selector, modifier);
} catch (err) {
Logger.error(`Error on setting shared external video start in Meetings collection: ${err}`);
}

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import { ExternalVideoMeetings } from '/imports/api/meetings';
export default function stopExternalVideo(userId, meetingId) {
export default async function stopExternalVideo(userId, meetingId) {
try {
check(meetingId, String);
check(userId, String);
@ -11,7 +11,7 @@ export default function stopExternalVideo(userId, meetingId) {
const modifier = { $set: { externalVideoUrl: null } };
Logger.info(`External video stop sharing was initiated by:[${userId}] for meeting ${meetingId}`);
ExternalVideoMeetings.update(selector, modifier);
await ExternalVideoMeetings.updateAsync(selector, modifier);
} catch (err) {
Logger.error(`Error on setting shared external video stop in Meetings collection: ${err}`);
}

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import ExternalVideoStreamer from '/imports/api/external-videos/server/streamer';
export default function updateExternalVideo(meetingId, userId, status, rate, time, state) {
export default async function updateExternalVideo(meetingId, userId, status, rate, time, state) {
try {
check(meetingId, String);
check(userId, String);

View File

@ -8,8 +8,8 @@ const GroupChatMsg = new Mongo.Collection('group-chat-msg');
const UsersTyping = new Mongo.Collection('users-typing', collectionOptions);
if (Meteor.isServer) {
GroupChatMsg._ensureIndex({ meetingId: 1, chatId: 1 });
UsersTyping._ensureIndex({ meetingId: 1, isTypingTo: 1 });
GroupChatMsg.createIndexAsync({ meetingId: 1, chatId: 1 });
UsersTyping.createIndexAsync({ meetingId: 1, isTypingTo: 1 });
}
// As we store chat in context, skip adding to mini mongo

View File

@ -1,12 +1,13 @@
import { check } from 'meteor/check';
import clearGroupChatMsg from '../modifiers/clearGroupChatMsg';
export default function clearPublicChatHistory({ header, body }) {
export default async function clearPublicChatHistory({ header, body }) {
const { meetingId } = header;
const { chatId } = body;
check(meetingId, String);
check(chatId, String);
return clearGroupChatMsg(meetingId, chatId);
const result = clearGroupChatMsg(meetingId, chatId);
return result;
}

View File

@ -9,7 +9,7 @@ const msgBuffer = [];
const bulkFn = _.throttle(addBulkGroupChatMsgs, bufferChatInsertsMs);
export default function handleGroupChatMsgBroadcast({ body }, meetingId) {
export default async function handleGroupChatMsgBroadcast({ body }, meetingId) {
const { chatId, msg } = body;
check(meetingId, String);
@ -20,6 +20,6 @@ export default function handleGroupChatMsgBroadcast({ body }, meetingId) {
msgBuffer.push({ meetingId, chatId, msg });
bulkFn(msgBuffer);
} else {
addGroupChatMsg(meetingId, chatId, msg);
await addGroupChatMsg(meetingId, chatId, msg);
}
}

View File

@ -1,12 +1,12 @@
import { check } from 'meteor/check';
import startTyping from '../modifiers/startTyping';
export default function handleUserTyping({ body }, meetingId) {
export default async function handleUserTyping({ body }, meetingId) {
const { chatId, userId } = body;
check(meetingId, String);
check(userId, String);
check(chatId, String);
startTyping(meetingId, userId, chatId);
await startTyping(meetingId, userId, chatId);
}

View File

@ -9,7 +9,7 @@ import Logger from '/imports/startup/server/logger';
const CHAT_CONFIG = Meteor.settings.public.chat;
const PUBLIC_CHAT_TYPE = CHAT_CONFIG.type_public;
export default function chatMessageBeforeJoinCounter() {
export default async function chatMessageBeforeJoinCounter() {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
@ -23,7 +23,7 @@ export default function chatMessageBeforeJoinCounter() {
],
}).fetch();
const User = Users.findOne({ userId: requesterUserId, meetingId });
const User = await Users.findOneAsync({ userId: requesterUserId, meetingId });
const chatIdWithCounter = groupChats.map((groupChat) => {
const msgCount = GroupChatMsg.find({
@ -40,4 +40,6 @@ export default function chatMessageBeforeJoinCounter() {
} catch (err) {
Logger.error(`Exception while invoking method chatMessageBeforeJoinCounter ${err.stack}`);
}
//True returned because the function requires a return.
return true;
}

View File

@ -8,7 +8,7 @@ import Logger from '/imports/startup/server/logger';
const CHAT_CONFIG = Meteor.settings.public.chat;
const ITENS_PER_PAGE = CHAT_CONFIG.itemsPerPage;
export default function fetchMessagePerPage(chatId, page) {
export default async function fetchMessagePerPage(chatId, page) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
@ -17,9 +17,9 @@ export default function fetchMessagePerPage(chatId, page) {
check(chatId, String);
check(page, Number);
const User = Users.findOne({ userId: requesterUserId, meetingId });
const User = await Users.findOneAsync({ userId: requesterUserId, meetingId });
const messages = GroupChatMsg.find(
const messages = await GroupChatMsg.find(
{ chatId, meetingId, timestamp: { $lt: User.authTokenValidatedTime } },
{
sort: { timestamp: 1 },
@ -27,9 +27,11 @@ export default function fetchMessagePerPage(chatId, page) {
limit: ITENS_PER_PAGE,
},
)
.fetch();
.fetchAsync();
return messages;
} catch (err) {
Logger.error(`Exception while invoking method fetchMessagePerPage ${err.stack}`);
}
//True returned because the function requires a return.
return true;
}

View File

@ -4,14 +4,14 @@ import { extractCredentials } from '/imports/api/common/server/helpers';
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
export default function stopUserTyping() {
export default async function stopUserTyping() {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
const userTyping = UsersTyping.findOne({
const userTyping = await UsersTyping.findOneAsync({
meetingId,
userId: requesterUserId,
});

View File

@ -21,10 +21,10 @@ export default async function addBulkGroupChatMsgs(msgs) {
message: parseMessage(msg.message),
sender: sender.id,
senderName: sender.name,
senderRole: sender.role
senderRole: sender.role,
};
})
.map(el => flat(el, { safe: true }));
.map((el) => flat(el, { safe: true }));
try {
const { insertedCount } = await GroupChatMsg.rawCollection().insertMany(mappedMsgs);

View File

@ -17,7 +17,7 @@ export function parseMessage(message) {
return parsedMessage;
}
export default function addGroupChatMsg(meetingId, chatId, msg) {
export default async function addGroupChatMsg(meetingId, chatId, msg) {
check(meetingId, String);
check(chatId, String);
check(msg, {
@ -45,10 +45,10 @@ export default function addGroupChatMsg(meetingId, chatId, msg) {
};
try {
const insertedId = GroupChatMsg.insert(msgDocument);
const insertedId = await GroupChatMsg.insertAsync(msgDocument);
if (insertedId) {
changeHasMessages(true, sender.id, meetingId, chatId);
await changeHasMessages(true, sender.id, meetingId, chatId);
Logger.info(`Added group-chat-msg msgId=${msg.id} chatId=${chatId} meetingId=${meetingId}`);
}
} catch (err) {

View File

@ -16,7 +16,7 @@ export function parseMessage(message) {
return parsedMessage;
}
export default function addSystemMsg(meetingId, chatId, msg) {
export default async function addSystemMsg(meetingId, chatId, msg) {
check(meetingId, String);
check(chatId, String);
check(msg, {
@ -37,7 +37,7 @@ export default function addSystemMsg(meetingId, chatId, msg) {
};
try {
const insertedId = GroupChatMsg.insert(msgDocument);
const insertedId = await GroupChatMsg.insertAsync(msgDocument);
if (insertedId) {
Logger.info(`Added system-msg msgId=${msg.id} chatId=${chatId} meetingId=${meetingId}`);

View File

@ -4,7 +4,7 @@ import addSystemMsg from '/imports/api/group-chat-msg/server/modifiers/addSystem
import clearChatHasMessages from '/imports/api/users-persistent-data/server/modifiers/clearChatHasMessages';
import UsersPersistentData from '/imports/api/users-persistent-data';
export default function clearGroupChatMsg(meetingId, chatId) {
export default async function clearGroupChatMsg(meetingId, chatId) {
const CHAT_CONFIG = Meteor.settings.public.chat;
const PUBLIC_CHAT_SYSTEM_ID = CHAT_CONFIG.system_userid;
const PUBLIC_GROUP_CHAT_ID = CHAT_CONFIG.public_group_id;
@ -13,7 +13,7 @@ export default function clearGroupChatMsg(meetingId, chatId) {
if (chatId) {
try {
const numberAffected = GroupChatMsg.remove({ meetingId, chatId });
const numberAffected = await GroupChatMsg.removeAsync({ meetingId, chatId });
if (numberAffected) {
Logger.info(`Cleared GroupChatMsg (${meetingId}, ${chatId})`);
@ -27,18 +27,17 @@ export default function clearGroupChatMsg(meetingId, chatId) {
},
message: CHAT_CLEAR_MESSAGE,
};
addSystemMsg(meetingId, PUBLIC_GROUP_CHAT_ID, clearMsg);
clearChatHasMessages(meetingId, chatId);
await addSystemMsg(meetingId, PUBLIC_GROUP_CHAT_ID, clearMsg);
await clearChatHasMessages(meetingId, chatId);
//clear offline users' data
const selector = {
meetingId,
'shouldPersist.hasConnectionStatus': { $ne: true },
'shouldPersist.hasMessages.private': { $ne: true },
loggedOut: true
loggedOut: true,
};
UsersPersistentData.remove(selector);
await UsersPersistentData.removeAsync(selector);
}
} catch (err) {
Logger.error(`Error on clearing GroupChat (${meetingId}, ${chatId}). ${err}`);
@ -48,7 +47,7 @@ export default function clearGroupChatMsg(meetingId, chatId) {
if (meetingId) {
try {
const numberAffected = GroupChatMsg.remove({ meetingId });
const numberAffected = await GroupChatMsg.removeAsync({ meetingId });
if (numberAffected) {
Logger.info(`Cleared GroupChatMsg (${meetingId})`);
@ -58,10 +57,11 @@ export default function clearGroupChatMsg(meetingId, chatId) {
}
} else {
try {
const numberAffected = GroupChatMsg.remove({ chatId: { $eq: PUBLIC_GROUP_CHAT_ID } });
const numberAffected = await GroupChatMsg
.removeAsync({ chatId: { $eq: PUBLIC_GROUP_CHAT_ID } });
if (numberAffected) {
clearChatHasMessages(meetingId, chatId=PUBLIC_GROUP_CHAT_ID);
await clearChatHasMessages(meetingId, chatId=PUBLIC_GROUP_CHAT_ID);
Logger.info('Cleared GroupChatMsg (all)');
}
@ -69,4 +69,6 @@ export default function clearGroupChatMsg(meetingId, chatId) {
Logger.error(`Error on clearing GroupChatMsg (all). ${err}`);
}
}
//True resturned because the function requires a return.
return true;
}

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import GroupChatMsg from '/imports/api/group-chat-msg';
export default function removeGroupChatMsg(meetingId, chatId) {
export default async function removeGroupChatMsg(meetingId, chatId) {
check(meetingId, String);
check(chatId, String);
@ -12,7 +12,7 @@ export default function removeGroupChatMsg(meetingId, chatId) {
};
try {
const numberAffected = GroupChatMsg.remove(selector);
const numberAffected = await GroupChatMsg.removeAsync(selector);
if (numberAffected) {
Logger.info(`Removed group-chat-msg id=${chatId} meeting=${meetingId}`);

View File

@ -6,7 +6,7 @@ import stopTyping from './stopTyping';
const TYPING_TIMEOUT = 5000;
export default function startTyping(meetingId, userId, chatId) {
export default async function startTyping(meetingId, userId, chatId) {
check(meetingId, String);
check(userId, String);
@ -15,7 +15,7 @@ export default function startTyping(meetingId, userId, chatId) {
userId,
};
const user = Users.findOne(selector, { fields: { name: 1, role: 1 } });
const user = await Users.findOneAsync(selector, { fields: { name: 1, role: 1 } });
const modifier = {
meetingId,
@ -26,7 +26,7 @@ export default function startTyping(meetingId, userId, chatId) {
time: (new Date()),
};
const typingUser = UsersTyping.findOne(selector, {
const typingUser = await UsersTyping.findOneAsync(selector, {
fields: {
time: 1,
},
@ -37,7 +37,7 @@ export default function startTyping(meetingId, userId, chatId) {
}
try {
const { numberAffected } = UsersTyping.upsert(selector, modifier);
const { numberAffected } = await UsersTyping.upsertAsync(selector, modifier);
if (numberAffected) {
Logger.debug('Typing indicator update', { userId, chatId });

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import { UsersTyping } from '/imports/api/group-chat-msg';
export default function stopTyping(meetingId, userId, sendMsgInitiated = false) {
export default async function stopTyping(meetingId, userId, sendMsgInitiated = false) {
check(meetingId, String);
check(userId, String);
check(sendMsgInitiated, Boolean);
@ -12,12 +12,12 @@ export default function stopTyping(meetingId, userId, sendMsgInitiated = false)
userId,
};
const user = UsersTyping.findOne(selector);
const user = await UsersTyping.findOneAsync(selector);
const stillTyping = !sendMsgInitiated && user && (new Date()) - user.time < 3000;
if (stillTyping) return;
try {
const numberAffected = UsersTyping.remove(selector);
const numberAffected = await UsersTyping.removeAsync(selector);
if (numberAffected) {
Logger.debug('Stopped typing indicator', { userId });

View File

@ -6,9 +6,10 @@ import GroupChat from '/imports/api/group-chat';
import Logger from '/imports/startup/server/logger';
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
function groupChatMsg(chatCount) {
async function groupChatMsg(chatCount) {
check(chatCount, Number);
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
const tokenValidation = await AuthTokenValidation
.findOneAsync({ connectionId: this.connection.id });
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
Logger.warn(`Publishing GroupChatMsg was requested by unauth connection ${this.connection.id}`);
@ -22,15 +23,15 @@ function groupChatMsg(chatCount) {
Logger.debug('Publishing group-chat-msg', { meetingId, userId });
const chats = GroupChat.find({
const chats = await GroupChat.find({
$or: [
{ meetingId, users: { $all: [userId] } },
],
}).fetch();
}).fetchAsync();
const chatsIds = chats.map((ct) => ct.chatId);
const User = Users.findOne({ userId, meetingId });
const User = await Users.findOneAsync({ userId, meetingId });
const selector = {
timestamp: { $gte: User.authTokenValidatedTime },
$or: [

View File

@ -7,7 +7,7 @@ const collectionOptions = Meteor.isClient ? {
const GroupChat = new Mongo.Collection('group-chat', collectionOptions);
if (Meteor.isServer) {
GroupChat._ensureIndex({
GroupChat.createIndexAsync({
meetingId: 1, chatId: 1, access: 1, users: 1,
});
}

View File

@ -1,9 +1,9 @@
import { check } from 'meteor/check';
import addGroupChat from '../modifiers/addGroupChat';
export default function handleGroupChatCreated({ body }, meetingId) {
export default async function handleGroupChatCreated({ body }, meetingId) {
check(meetingId, String);
check(body, Object);
addGroupChat(meetingId, body);
await addGroupChat(meetingId, body);
}

View File

@ -1,9 +1,9 @@
import { check } from 'meteor/check';
import addGroupChat from '../modifiers/addGroupChat';
export default function handleGroupChatDestroyed({ body }, meetingId) {
export default async function handleGroupChatDestroyed({ body }, meetingId) {
check(meetingId, String);
check(body, Object);
addGroupChat(meetingId, body);
await addGroupChat(meetingId, body);
}

View File

@ -1,11 +1,14 @@
import { check } from 'meteor/check';
import addGroupChat from '../modifiers/addGroupChat';
export default function handleGroupChats({ body }, meetingId) {
export default async function handleGroupChats({ body }, meetingId) {
const { chats } = body;
check(meetingId, String);
check(chats, Array);
chats.forEach(chat => addGroupChat(meetingId, chat));
await new Promise
.all(chats.map(async (chat) => {
await addGroupChat(meetingId, chat);
}));
}

View File

@ -3,7 +3,7 @@ import { Match, check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import GroupChat from '/imports/api/group-chat';
export default function addGroupChat(meetingId, chat) {
export default async function addGroupChat(meetingId, chat) {
check(meetingId, String);
check(chat, {
id: Match.Maybe(String),
@ -34,7 +34,7 @@ export default function addGroupChat(meetingId, chat) {
};
try {
const { insertedId } = GroupChat.upsert(selector, modifier);
const { insertedId } = await GroupChat.upsertAsync(selector, modifier);
if (insertedId) {
Logger.info(`Added group-chat chatId=${chatDocument.chatId} meetingId=${meetingId}`);

View File

@ -2,10 +2,10 @@ import GroupChat from '/imports/api/group-chat';
import Logger from '/imports/startup/server/logger';
import clearGroupChatMsg from '/imports/api/group-chat-msg/server/modifiers/clearGroupChatMsg';
export default function clearGroupChat(meetingId) {
export default async function clearGroupChat(meetingId) {
try {
clearGroupChatMsg(meetingId);
const numberAffected = GroupChat.remove({ meetingId });
await clearGroupChatMsg(meetingId);
const numberAffected = await GroupChat.removeAsync({ meetingId });
if (numberAffected) {
Logger.info(`Cleared GroupChat (${meetingId})`);

View File

@ -3,7 +3,7 @@ import Logger from '/imports/startup/server/logger';
import GroupChat from '/imports/api/group-chat';
import clearGroupChatMsg from '/imports/api/group-chat-msg/server/modifiers/clearGroupChatMsg';
export default function removeGroupChat(meetingId, chatId) {
export default async function removeGroupChat(meetingId, chatId) {
check(meetingId, String);
check(chatId, String);
@ -13,7 +13,7 @@ export default function removeGroupChat(meetingId, chatId) {
};
try {
const numberAffected = GroupChat.remove(selector);
const numberAffected = await GroupChat.removeAsync(selector);
if (numberAffected) {
Logger.info(`Removed group-chat id=${chatId} meeting=${meetingId}`);

View File

@ -4,8 +4,9 @@ import { Meteor } from 'meteor/meteor';
import Logger from '/imports/startup/server/logger';
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
function groupChat() {
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
async function groupChat() {
const tokenValidation = await AuthTokenValidation
.findOneAsync({ connectionId: this.connection.id });
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
Logger.warn(`Publishing GroupChat was requested by unauth connection ${this.connection.id}`);

View File

@ -1,11 +1,15 @@
import { check } from 'meteor/check';
import setGuestStatus from '../modifiers/setGuestStatus';
export default function handleGuestApproved({ body }, meetingId) {
export default async function handleGuestApproved({ body }, meetingId) {
const { approvedBy, guests } = body;
check(meetingId, String);
check(approvedBy, String);
check(guests, Array);
return guests.forEach(guest => setGuestStatus(meetingId, guest.guest, guest.status, approvedBy));
const result = await Promise.all(guests.map(async (guest) => {
const a = await setGuestStatus(meetingId, guest.guest, guest.status, approvedBy);
return a;
}));
return result;
}

View File

@ -1,10 +1,11 @@
import { check } from 'meteor/check';
import removeGuest from '../modifiers/removeGuest';
export default function handleGuestWaitingLeft({ body }, meetingId) {
export default async function handleGuestWaitingLeft({ body }, meetingId) {
const { userId } = body;
check(meetingId, String);
check(userId, String);
return removeGuest(meetingId, userId);
const result = await removeGuest(meetingId, userId);
return result;
}

View File

@ -3,14 +3,14 @@ import Logger from '/imports/startup/server/logger';
import GuestUsers from '/imports/api/guest-users/';
import updatePositionInWaitingQueue from '../methods/updatePositionInWaitingQueue';
export default function handleGuestsWaitingForApproval({ body }, meetingId) {
export default async function handleGuestsWaitingForApproval({ body }, meetingId) {
const { guests } = body;
check(guests, Array);
check(meetingId, String);
return guests.map((guest) => {
const result = await Promise.all(guests.map(async (guest) => {
try {
const { insertedId, numberAffected } = GuestUsers.upsert({
const { insertedId, numberAffected } = await GuestUsers.upsertAsync({
meetingId,
intId: guest.intId,
}, {
@ -37,5 +37,6 @@ export default function handleGuestsWaitingForApproval({ body }, meetingId) {
} catch (err) {
Logger.error(`Adding guest user to collection: ${err}`);
}
});
}));
return result;
}

View File

@ -1,13 +1,13 @@
import { check } from 'meteor/check';
import setPrivateGuestLobbyMessage from '../modifiers/setPrivateGuestLobbyMessage';
export default function handlePrivateGuestLobbyMessageChanged({ body }, meetingId) {
const {guestId, message } = body;
export default async function handlePrivateGuestLobbyMessageChanged({ body }, meetingId) {
const { guestId, message } = body;
check(meetingId, String);
check(guestId, String)
check(guestId, String);
check(message, String);
setPrivateGuestLobbyMessage(meetingId, guestId, message);
const result = await setPrivateGuestLobbyMessage(meetingId, guestId, message);
return result;
}

View File

@ -4,32 +4,31 @@ import RedisPubSub from '/imports/startup/server/redis';
import Logger from '/imports/startup/server/logger';
import GuestUsers from '/imports/api/guest-users/';
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'UpdatePositionInWaitingQueueReqMsg';
export default function updatePositionInWaitingQueue(meetingId) {
export default async function updatePositionInWaitingQueue(meetingId) {
check(meetingId, String);
const guestUsers = GuestUsers.find({
meetingId: meetingId,
const guestUsers = await GuestUsers.find({
meetingId,
approved: false,
denied: false,
}).fetch();
}).fetchAsync();
check(guestUsers, Array);
try {
const guests = guestUsers.map(guest => ({intId: guest.intId, idx: String(guestUsers.indexOf(guest)+1)}));
const guests = guestUsers.map((guest) => ({
intId: guest.intId,
idx: String(guestUsers.indexOf(guest) + 1),
}));
check(guests, Array);
const payload = { guests };
Logger.info(`The waiting positions of the guest users will be updated`);
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, "not-used", payload);
Logger.info('The waiting positions of the guest users will be updated');
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, 'not-used', payload);
} catch (err) {
Logger.error(`Exception while invoking method updatePositionInWaitingQueue ${err.stack}`);
}
}

View File

@ -1,10 +1,10 @@
import GuestUsers from '/imports/api/guest-users';
import Logger from '/imports/startup/server/logger';
export default function clearGuestUsers(meetingId) {
export default async function clearGuestUsers(meetingId) {
if (meetingId) {
try {
const numberAffected = GuestUsers.remove({ meetingId });
const numberAffected = await GuestUsers.removeAsync({ meetingId });
if (numberAffected) {
Logger.info(`Cleared GuestUsers in (${meetingId})`);
@ -14,7 +14,7 @@ export default function clearGuestUsers(meetingId) {
}
} else {
try {
const numberAffected = GuestUsers.remove({});
const numberAffected = await GuestUsers.removeAsync({});
if (numberAffected) {
Logger.info('Cleared GuestUsers in all meetings');

View File

@ -3,7 +3,7 @@ import GuestUsers from '/imports/api/guest-users';
import Logger from '/imports/startup/server/logger';
import updatePositionInWaitingQueue from '../methods/updatePositionInWaitingQueue';
export default function removeGuest(meetingId, intId) {
export default async function removeGuest(meetingId, intId) {
check(meetingId, String);
check(intId, String);
@ -12,18 +12,17 @@ export default function removeGuest(meetingId, intId) {
intId,
};
const cb = (err) => {
if (err) {
try {
const result = await GuestUsers.removeAsync(selector);
if (result) {
Logger.info(`Removed guest user id=${intId} meetingId=${meetingId}`);
}
} catch (err) {
return Logger.error(`Removing guest user from collection: ${err}`);
}
/**
* Update position of waiting users after user has left the guest lobby
*/
updatePositionInWaitingQueue(meetingId);
// Update position of waiting users after user has left the guest lobby.
await updatePositionInWaitingQueue(meetingId);
return Logger.info(`Removed guest user id=${intId} meetingId=${meetingId}`);
};
return GuestUsers.remove(selector, cb);
return true;
}

View File

@ -5,7 +5,7 @@ import updatePositionInWaitingQueue from '../methods/updatePositionInWaitingQueu
const GUEST_STATUS_ALLOW = 'ALLOW';
const GUEST_STATUS_DENY = 'DENY';
export default function setGuestStatus(meetingId, intId, status, approvedBy = null) {
export default async function setGuestStatus(meetingId, intId, status, approvedBy = null) {
check(meetingId, String);
check(intId, String);
check(status, String);
@ -24,14 +24,14 @@ export default function setGuestStatus(meetingId, intId, status, approvedBy = nu
};
try {
const numberAffected = GuestUsers.update(selector, modifier);
const numberAffected = await GuestUsers.updateAsync(selector, modifier);
if (numberAffected) {
Logger.info(`Updated status=${status} user=${intId} meeting=${meetingId}`);
/** Update position of waiting users after user has been
* approved or denied by the moderator
*/
updatePositionInWaitingQueue(meetingId);
await updatePositionInWaitingQueue(meetingId);
}
} catch (err) {
Logger.error(`Updating status=${status} user=${intId}: ${err}`);

View File

@ -2,12 +2,12 @@ import GuestUsers from '/imports/api/guest-users';
import Logger from '/imports/startup/server/logger';
import { check } from 'meteor/check';
export default function setPrivateGuestLobbyMessage(meetingId, guestId, guestLobbyMessage) {
export default async function setPrivateGuestLobbyMessage(meetingId, guestId, guestLobbyMessage) {
check(meetingId, String);
check(guestId, String);
check(guestLobbyMessage, String);
const intId=guestId;
const intId = guestId;
const selector = {
meetingId,
@ -21,7 +21,7 @@ export default function setPrivateGuestLobbyMessage(meetingId, guestId, guestLob
};
try {
const numberAffected = GuestUsers.update(selector, modifier);
const numberAffected = await GuestUsers.updateAsync(selector, modifier);
if (numberAffected) {
Logger.verbose(`Set a private guest lobby message meetingId=${meetingId} for guest user=${guestId} to guestLobbyMessage=${guestLobbyMessage}`);
@ -30,4 +30,3 @@ export default function setPrivateGuestLobbyMessage(meetingId, guestId, guestLob
Logger.error(`Setting a private guest lobby message to ${guestId}: ${err}`);
}
}

View File

@ -7,8 +7,9 @@ import { publicationSafeGuard } from '/imports/api/common/server/helpers';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
function guestUsers() {
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
async function guestUsers() {
const tokenValidation = await AuthTokenValidation
.findOneAsync({ connectionId: this.connection.id });
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
Logger.warn(`Publishing GuestUser was requested by unauth connection ${this.connection.id}`);
@ -17,7 +18,7 @@ function guestUsers() {
const { meetingId, userId } = tokenValidation;
const User = Users.findOne({ userId, meetingId }, { fields: { role: 1 } });
const User = await Users.findOneAsync({ userId, meetingId }, { fields: { role: 1 } });
if (!User || User.role !== ROLE_MODERATOR) {
Logger.warn(
'Publishing GuestUser was requested by non-moderator connection',
@ -27,8 +28,9 @@ function guestUsers() {
return GuestUsers.find({ meetingId: '' });
}
// Monitor this publication and stop it when user is not a moderator anymore
const comparisonFunc = () => {
const user = Users.findOne({ userId, meetingId }, { fields: { role: 1, userId: 1 } });
const comparisonFunc = async () => {
const user = await Users
.findOneAsync({ userId, meetingId }, { fields: { role: 1, userId: 1 } });
const condition = user.role === ROLE_MODERATOR;
if (!condition) {

View File

@ -3,7 +3,7 @@ import { Meteor } from 'meteor/meteor';
const LocalSettings = new Mongo.Collection('local-settings');
if (Meteor.isServer) {
LocalSettings._ensureIndex({
LocalSettings.createIndexAsync({
meetingId: 1, userId: 1,
});
}

View File

@ -5,7 +5,7 @@ import setChangedLocalSettings from '../modifiers/setChangedLocalSettings';
import { extractCredentials } from '/imports/api/common/server/helpers';
import Logger from '/imports/startup/server/logger';
export default function userChangedLocalSettings(settings) {
export default async function userChangedLocalSettings(settings) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
@ -15,14 +15,14 @@ export default function userChangedLocalSettings(settings) {
check(meetingId, String);
check(requesterUserId, String);
const userLocalSettings = LocalSettings
.findOne({ meetingId, userId: requesterUserId },
const userLocalSettings = await LocalSettings
.findOneAsync({ meetingId, userId: requesterUserId },
{
fields: { settings: 1 },
});
if (!userLocalSettings || !_.isEqual(userLocalSettings.settings, settings)) {
setChangedLocalSettings(meetingId, requesterUserId, settings);
await setChangedLocalSettings(meetingId, requesterUserId, settings);
}
} catch (err) {
Logger.error(`Exception while invoking method userChangedLocalSettings ${err.stack}`);

View File

@ -1,9 +1,9 @@
import LocalSettings from '/imports/api/local-settings';
import Logger from '/imports/startup/server/logger';
export default function clearLocalSettings(meetingId) {
export default async function clearLocalSettings(meetingId) {
try {
const numberAffected = LocalSettings.remove({ meetingId });
const numberAffected = await LocalSettings.removeAsync({ meetingId });
if (numberAffected) {
Logger.info(`Cleared Local Settings (${meetingId})`);

View File

@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import LocalSettings from '/imports/api/local-settings';
import Logger from '/imports/startup/server/logger';
export default function setChangedLocalSettings(meetingId, userId, settings) {
export default async function setChangedLocalSettings(meetingId, userId, settings) {
check(meetingId, String);
check(userId, String);
check(settings, Object);
@ -19,7 +19,7 @@ export default function setChangedLocalSettings(meetingId, userId, settings) {
};
try {
const { numChanged } = LocalSettings.upsert(selector, modifier);
const { numChanged } = await LocalSettings.upsertAsync(selector, modifier);
if (numChanged) {
Logger.info(`Updated settings for user ${userId} on meeting ${meetingId}`);

View File

@ -3,8 +3,9 @@ import LocalSettings from '/imports/api/local-settings';
import Logger from '/imports/startup/server/logger';
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
function localSettings() {
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
async function localSettings() {
const tokenValidation = await AuthTokenValidation
.findOneAsync({ connectionId: this.connection.id });
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
Logger.warn(`Publishing LocalSettings was requested by unauth connection ${this.connection.id}`);

View File

@ -15,11 +15,11 @@ if (Meteor.isServer) {
// types of queries for the meetings:
// 1. meetingId
Meetings._ensureIndex({ meetingId: 1 });
RecordMeetings._ensureIndex({ meetingId: 1 });
ExternalVideoMeetings._ensureIndex({ meetingId: 1 });
MeetingTimeRemaining._ensureIndex({ meetingId: 1 });
LayoutMeetings._ensureIndex({ meetingId: 1 });
Meetings.createIndexAsync({ meetingId: 1 });
RecordMeetings.createIndexAsync({ meetingId: 1 });
ExternalVideoMeetings.createIndexAsync({ meetingId: 1 });
MeetingTimeRemaining.createIndexAsync({ meetingId: 1 });
LayoutMeetings.createIndexAsync({ meetingId: 1 });
}
export {

View File

@ -1,7 +1,27 @@
import changeLayout from '../modifiers/changeLayout';
export default function broadcastLayout({ body }, meetingId) {
const { layout, presentationIsOpen, isResizing, cameraPosition, focusedCamera, presentationVideoRate, pushLayout, setByUserId } = body;
export default async function broadcastLayout({ body }, meetingId) {
const {
layout,
presentationIsOpen,
isResizing,
cameraPosition,
focusedCamera,
presentationVideoRate,
pushLayout,
setByUserId,
} = body;
changeLayout(meetingId, layout, presentationIsOpen, isResizing, cameraPosition, focusedCamera, presentationVideoRate, pushLayout, setByUserId);
const result = await changeLayout(
meetingId,
layout,
presentationIsOpen,
isResizing,
cameraPosition,
focusedCamera,
presentationVideoRate,
pushLayout,
setByUserId,
);
return result;
}

View File

@ -1,7 +1,8 @@
import setPushLayout from '../modifiers/setPushLayout';
export default function broadcastPushLayout({ body }, meetingId) {
export default async function broadcastPushLayout({ body }, meetingId) {
const { pushLayout, setByUserId } = body;
setPushLayout(meetingId, pushLayout, setByUserId);
const result = await setPushLayout(meetingId, pushLayout, setByUserId);
return result;
}

View File

@ -1,5 +1,6 @@
import handleMeetingCreation from './meetingCreation';
export default function handleGetAllMeetings({ body }) {
return handleMeetingCreation({ body });
export default async function handleGetAllMeetings({ body }) {
const result = await handleMeetingCreation({ body });
return result;
}

View File

@ -1,11 +1,11 @@
import setGuestLobbyMessage from '../modifiers/setGuestLobbyMessage';
import { check } from 'meteor/check';
import setGuestLobbyMessage from '../modifiers/setGuestLobbyMessage';
export default function handleGuestLobbyMessageChanged({ body }, meetingId) {
export default async function handleGuestLobbyMessageChanged({ body }, meetingId) {
const { message } = body;
check(meetingId, String);
check(message, String);
return setGuestLobbyMessage(meetingId, message);
const result = await setGuestLobbyMessage(meetingId, message);
return result;
}

View File

@ -1,12 +1,12 @@
import setGuestPolicy from '../modifiers/setGuestPolicy';
import { check } from 'meteor/check';
import setGuestPolicy from '../modifiers/setGuestPolicy';
export default function handleGuestPolicyChanged({ body }, meetingId) {
export default async function handleGuestPolicyChanged({ body }, meetingId) {
const { policy } = body;
check(meetingId, String);
check(policy, String);
return setGuestPolicy(meetingId, policy);
const result = await setGuestPolicy(meetingId, policy);
return result;
}

View File

@ -1,11 +1,11 @@
import { check } from 'meteor/check';
import addMeeting from '../modifiers/addMeeting';
export default function handleMeetingCreation({ body }) {
export default async function handleMeetingCreation({ body }) {
const meeting = body.props;
const durationInSecods = (meeting.durationProps.duration * 60);
meeting.durationProps.timeRemaining = durationInSecods;
check(meeting, Object);
return addMeeting(meeting);
const result = await addMeeting(meeting);
return result;
}

Some files were not shown because too many files have changed in this diff Show More