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
|
|
|
|
|
|
|
export default function handleTimeRemainingUpdate({ body }, meetingId) {
|
|
|
|
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 {
|
|
|
|
MeetingTimeRemaining.upsert(selector, modifier);
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Changing recording time: ${err}`);
|
|
|
|
}
|
2022-02-21 19:14:34 +08:00
|
|
|
|
|
|
|
if (timeUpdatedInMinutes > 0) {
|
|
|
|
const Meeting = Meetings.findOne({ meetingId });
|
|
|
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
|
|
|
addSystemMsg(meetingId, PUBLIC_GROUP_CHAT_ID, payload);
|
|
|
|
}
|
|
|
|
}
|
2019-01-24 00:13:03 +08:00
|
|
|
}
|