2022-07-20 03:36:00 +08:00
|
|
|
import addSystemMsg from '/imports/api/group-chat-msg/server/modifiers/addSystemMsg';
|
|
|
|
import Presentations from '/imports/api/presentations';
|
|
|
|
|
2022-07-25 20:19:39 +08:00
|
|
|
const DEFAULT_FILENAME = 'annotated_slides.pdf';
|
2022-07-20 03:36:00 +08:00
|
|
|
|
2023-05-12 05:06:48 +08:00
|
|
|
export default async function sendExportedPresentationChatMsg(meetingId,
|
|
|
|
presentationId, fileURI, typeOfExport) {
|
2022-07-20 03:36:00 +08:00
|
|
|
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;
|
2023-05-12 05:06:48 +08:00
|
|
|
const CHAT_EXPORTED_PRESENTATION_MESSAGE = CHAT_CONFIG
|
|
|
|
.system_messages_keys.chat_exported_presentation;
|
2022-07-20 03:36:00 +08:00
|
|
|
const SYSTEM_CHAT_TYPE = CHAT_CONFIG.type_system;
|
|
|
|
|
2023-03-15 01:27:52 +08:00
|
|
|
const pres = await Presentations.findOneAsync({ meetingId, id: presentationId });
|
2022-07-20 03:36:00 +08:00
|
|
|
|
|
|
|
const extra = {
|
|
|
|
type: 'presentation',
|
|
|
|
fileURI,
|
|
|
|
filename: pres?.name || DEFAULT_FILENAME,
|
2023-04-17 20:04:58 +08:00
|
|
|
typeOfExport,
|
2022-07-20 03:36:00 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
id: `${SYSTEM_CHAT_TYPE}-${CHAT_EXPORTED_PRESENTATION_MESSAGE}`,
|
|
|
|
timestamp: Date.now(),
|
|
|
|
correlationId: `${PUBLIC_CHAT_SYSTEM_ID}-${Date.now()}`,
|
|
|
|
sender: {
|
|
|
|
id: PUBLIC_CHAT_SYSTEM_ID,
|
|
|
|
name: '',
|
|
|
|
},
|
|
|
|
message: '',
|
|
|
|
extra,
|
|
|
|
};
|
2023-03-15 01:27:52 +08:00
|
|
|
const result = await addSystemMsg(meetingId, PUBLIC_GROUP_CHAT_ID, payload);
|
|
|
|
return result;
|
2022-07-20 03:36:00 +08:00
|
|
|
}
|