Make all handlers async
This commit is contained in:
parent
593333200d
commit
2553c44643
@ -1,9 +1,9 @@
|
|||||||
import { check } from 'meteor/check';
|
import { check } from 'meteor/check';
|
||||||
import clearBreakouts from '../modifiers/clearBreakouts';
|
import clearBreakouts from '../modifiers/clearBreakouts';
|
||||||
|
|
||||||
export default function handleBreakoutClosed({ body }) {
|
export default async function handleBreakoutClosed({ body }) {
|
||||||
const { breakoutId } = body;
|
const { breakoutId } = body;
|
||||||
check(breakoutId, String);
|
check(breakoutId, String);
|
||||||
|
const result = await clearBreakouts(breakoutId);
|
||||||
return clearBreakouts(breakoutId);
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import { check } from 'meteor/check';
|
|||||||
import Logger from '/imports/startup/server/logger';
|
import Logger from '/imports/startup/server/logger';
|
||||||
import Breakouts from '/imports/api/breakouts';
|
import Breakouts from '/imports/api/breakouts';
|
||||||
|
|
||||||
export default function handleBreakoutJoinURL({ body }) {
|
export default async function handleBreakoutJoinURL({ body }) {
|
||||||
const {
|
const {
|
||||||
redirectToHtml5JoinURL,
|
redirectToHtml5JoinURL,
|
||||||
userId,
|
userId,
|
||||||
@ -32,7 +32,7 @@ export default function handleBreakoutJoinURL({ body }) {
|
|||||||
numberAffected = await Breakouts.updateAsync(selector, modifier);
|
numberAffected = await Breakouts.updateAsync(selector, modifier);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateBreakoutPromise = new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
const updateBreakoutInterval = setInterval(async () => {
|
const updateBreakoutInterval = setInterval(async () => {
|
||||||
await updateBreakout();
|
await updateBreakout();
|
||||||
if (numberAffected) {
|
if (numberAffected) {
|
||||||
@ -40,10 +40,7 @@ export default function handleBreakoutJoinURL({ body }) {
|
|||||||
}
|
}
|
||||||
}, ATTEMPT_EVERY_MS);
|
}, ATTEMPT_EVERY_MS);
|
||||||
});
|
});
|
||||||
|
Logger.info(`Upserted breakout id=${breakoutId}`);
|
||||||
updateBreakoutPromise.then(() => {
|
|
||||||
Logger.info(`Upserted breakout id=${breakoutId}`);
|
|
||||||
});
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Logger.error(`Adding breakout to collection: ${err}`);
|
Logger.error(`Adding breakout to collection: ${err}`);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { check } from 'meteor/check';
|
|||||||
import flat from 'flat';
|
import flat from 'flat';
|
||||||
import handleBreakoutRoomsListHist from '/imports/api/breakouts-history/server/handlers/breakoutRoomsList';
|
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
|
// 0 seconds default breakout time, forces use of real expiration time
|
||||||
const DEFAULT_TIME_REMAINING = 0;
|
const DEFAULT_TIME_REMAINING = 0;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ export default function handleBreakoutRoomsList({ body }, meetingId) {
|
|||||||
} = body;
|
} = body;
|
||||||
|
|
||||||
// set firstly the last seq, then client will know when receive all
|
// 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;
|
const { breakoutId, html5JoinUrls, ...breakoutWithoutUrls } = breakout;
|
||||||
|
|
||||||
check(meetingId, String);
|
check(meetingId, String);
|
||||||
@ -43,15 +43,13 @@ export default function handleBreakoutRoomsList({ body }, meetingId) {
|
|||||||
...urls,
|
...urls,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
Breakouts.upsertAsync(selector, modifier).then((res) => {
|
const numberAffected = await Breakouts.upsertAsync(selector, modifier);
|
||||||
if (res.numberAffected) {
|
if (numberAffected) {
|
||||||
Logger.info('Updated timeRemaining and externalMeetingId '
|
Logger.info('Updated timeRemaining and externalMeetingId '
|
||||||
+ `for breakout id=${breakoutId}`);
|
+ `for breakout id=${breakoutId}`);
|
||||||
}
|
} else {
|
||||||
}).catch((err) => {
|
Logger.error(`updating breakout: ${numberAffected}`);
|
||||||
Logger.error(`updating breakout: ${err}`);
|
}
|
||||||
}).finally(() => {
|
handleBreakoutRoomsListHist({ body });
|
||||||
handleBreakoutRoomsListHist({ body });
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import Logger from '/imports/startup/server/logger';
|
|||||||
import { check } from 'meteor/check';
|
import { check } from 'meteor/check';
|
||||||
import { lowercaseTrim } from '/imports/utils/string-utils';
|
import { lowercaseTrim } from '/imports/utils/string-utils';
|
||||||
|
|
||||||
export default function joinedUsersChanged({ body }) {
|
export default async function joinedUsersChanged({ body }) {
|
||||||
check(body, Object);
|
check(body, Object);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -22,20 +22,29 @@ export default function joinedUsersChanged({ body }) {
|
|||||||
breakoutId,
|
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 = {
|
const modifier = {
|
||||||
$set: {
|
$set: {
|
||||||
joinedUsers: usersMapped,
|
joinedUsers: usersMapped,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
Breakouts.updateAsync(selector, modifier).then((res) => {
|
const numberAffected = await Breakouts.updateAsync(selector, modifier);
|
||||||
if (res.numberAffected) {
|
if (numberAffected) {
|
||||||
updateUserBreakoutRoom(parentId, breakoutId, users);
|
updateUserBreakoutRoom(parentId, breakoutId, users);
|
||||||
|
|
||||||
Logger.info(`Updated joined users in breakout id=${breakoutId}`);
|
Logger.info(`Updated joined users in breakout id=${breakoutId}`);
|
||||||
}
|
} else {
|
||||||
}).catch((err) => {
|
Logger.error(`updating joined users in breakout: ${numberAffected}`);
|
||||||
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}`);
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import { check } from 'meteor/check';
|
|||||||
import Logger from '/imports/startup/server/logger';
|
import Logger from '/imports/startup/server/logger';
|
||||||
import Breakouts from '/imports/api/breakouts';
|
import Breakouts from '/imports/api/breakouts';
|
||||||
|
|
||||||
export default function handleUpdateTimeRemaining({ body }, meetingId) {
|
export default async function handleUpdateTimeRemaining({ body }, meetingId) {
|
||||||
const {
|
const {
|
||||||
timeRemaining,
|
timeRemaining,
|
||||||
} = body;
|
} = body;
|
||||||
@ -23,11 +23,11 @@ export default function handleUpdateTimeRemaining({ body }, meetingId) {
|
|||||||
const options = {
|
const options = {
|
||||||
multi: true,
|
multi: true,
|
||||||
};
|
};
|
||||||
Breakouts.updateAsync(selector, modifier, options).then((res) => {
|
const numberAffected = Breakouts.updateAsync(selector, modifier, options);
|
||||||
if (res.numberAffected) {
|
|
||||||
Logger.info(`Updated breakout time remaining for breakouts where parentMeetingId=${meetingId}`);
|
if (numberAffected) {
|
||||||
}
|
Logger.info(`Updated breakout time remaining for breakouts where parentMeetingId=${meetingId}`);
|
||||||
}).catch((err) => {
|
} else {
|
||||||
Logger.error(`Updating breakouts: ${err}`);
|
Logger.error(`Updating breakouts: ${numberAffected}`);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user