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-04-01 04:40:41 +08:00
|
|
|
export default async function sendExportedPresentationChatMsg(meetingId, presentationId, fileURI) {
|
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-19 21:54:29 +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-04-01 04:40:41 +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,
|
|
|
|
};
|
|
|
|
|
|
|
|
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-04-01 04:40:41 +08:00
|
|
|
const result = await addSystemMsg(meetingId, PUBLIC_GROUP_CHAT_ID, payload);
|
|
|
|
return result;
|
2022-07-20 03:36:00 +08:00
|
|
|
}
|