2022-01-29 01:41:10 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import BreakoutsHistory from '/imports/api/breakouts-history';
|
|
|
|
|
2023-03-09 21:55:50 +08:00
|
|
|
export default async function handleSendMessageToAllBreakoutRoomsEvtMsg({ body }, meetingId) {
|
2022-01-29 01:41:10 +08:00
|
|
|
const {
|
|
|
|
senderId,
|
|
|
|
msg,
|
|
|
|
totalOfRooms,
|
|
|
|
} = body;
|
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
check(senderId, String);
|
|
|
|
check(msg, String);
|
|
|
|
check(totalOfRooms, Number);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$push: {
|
|
|
|
broadcastMsgs: {
|
|
|
|
senderId,
|
|
|
|
msg,
|
|
|
|
totalOfRooms,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
try {
|
2023-03-09 21:55:50 +08:00
|
|
|
const { insertedId } = await BreakoutsHistory.upsertAsync(selector, modifier);
|
2022-01-29 01:41:10 +08:00
|
|
|
|
|
|
|
if (insertedId) {
|
|
|
|
Logger.info(`Added broadCastMsg to breakout-history Data: meeting=${meetingId}`);
|
|
|
|
} else {
|
|
|
|
Logger.info(`Upserted broadCastMsg to breakout-history Data: meeting=${meetingId}`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Adding broadCastMsg to the collection breakout-history: ${err}`);
|
|
|
|
}
|
|
|
|
}
|