2019-01-24 00:13:03 +08:00
|
|
|
import { check } from 'meteor/check';
|
2022-02-21 19:14:34 +08:00
|
|
|
import Meetings, { MeetingTimeRemaining } from '/imports/api/meetings';
|
2019-01-24 00:13:03 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2022-02-21 19:14:34 +08:00
|
|
|
import addSystemMsg from '/imports/api/group-chat-msg/server/modifiers/addSystemMsg';
|
2019-01-24 00:13:03 +08:00
|
|
|
|
2023-03-14 00:59:52 +08:00
|
|
|
export default async function handleTimeRemainingUpdate({ body }, meetingId) {
|
2019-01-24 00:13:03 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
|
|
|
|
check(body, {
|
|
|
|
timeLeftInSec: Number,
|
2022-02-21 19:14:34 +08:00
|
|
|
timeUpdatedInMinutes: Number,
|
2019-01-24 00:13:03 +08:00
|
|
|
});
|
2022-02-21 19:14:34 +08:00
|
|
|
const { timeLeftInSec, timeUpdatedInMinutes } = body;
|
2019-01-24 00:13:03 +08:00
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
2019-09-09 22:29:59 +08:00
|
|
|
timeRemaining: timeLeftInSec,
|
2019-01-24 00:13:03 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-25 21:54:18 +08:00
|
|
|
try {
|
2023-03-14 00:59:52 +08:00
|
|
|
await MeetingTimeRemaining.upsertAsync(selector, modifier);
|
2020-11-25 21:54:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Changing recording time: ${err}`);
|
|
|
|
}
|
2022-02-21 19:14:34 +08:00
|
|
|
|
|
|
|
if (timeUpdatedInMinutes > 0) {
|
2023-03-14 00:59:52 +08:00
|
|
|
const Meeting = await Meetings.findOneAsync({ meetingId });
|
2022-02-21 19:14:34 +08:00
|
|
|
|
|
|
|
if (Meeting.meetingProp.isBreakout) {
|
|
|
|
const CHAT_CONFIG = Meteor.settings.public.chat;
|
|
|
|
const PUBLIC_GROUP_CHAT_ID = CHAT_CONFIG.public_group_id;
|
|
|
|
const PUBLIC_CHAT_SYSTEM_ID = CHAT_CONFIG.system_userid;
|
|
|
|
const PUBLIC_CHAT_INFO = CHAT_CONFIG.system_messages_keys.chat_info;
|
|
|
|
const SYSTEM_CHAT_TYPE = CHAT_CONFIG.type_system;
|
|
|
|
|
|
|
|
const messageValues = {
|
|
|
|
0: timeUpdatedInMinutes,
|
|
|
|
};
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
id: `${SYSTEM_CHAT_TYPE}-${PUBLIC_CHAT_INFO}`,
|
|
|
|
timestamp: Date.now(),
|
|
|
|
correlationId: `${PUBLIC_CHAT_SYSTEM_ID}-${Date.now()}`,
|
|
|
|
sender: {
|
|
|
|
id: PUBLIC_CHAT_SYSTEM_ID,
|
|
|
|
name: '',
|
|
|
|
},
|
|
|
|
message: 'breakoutDurationUpdated',
|
|
|
|
messageValues,
|
|
|
|
};
|
|
|
|
|
2023-03-14 00:59:52 +08:00
|
|
|
await addSystemMsg(meetingId, PUBLIC_GROUP_CHAT_ID, payload);
|
2022-02-21 19:14:34 +08:00
|
|
|
}
|
|
|
|
}
|
2019-01-24 00:13:03 +08:00
|
|
|
}
|