bigbluebutton-Github/bigbluebutton-html5/imports/api/group-chat-msg/server/modifiers/clearGroupChatMsg.js

39 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-08-08 23:12:53 +08:00
import { GroupChatMsg } from '/imports/api/group-chat-msg';
import Logger from '/imports/startup/server/logger';
import addGroupChatMsg from '/imports/api/group-chat-msg/server/modifiers/addGroupChatMsg';
export default function clearGroupChatMsg(meetingId, chatId) {
const CHAT_CONFIG = Meteor.settings.public.chat;
const PUBLIC_CHAT_SYSTEM_ID = CHAT_CONFIG.system_userid;
const PUBLIC_GROUP_CHAT_ID = CHAT_CONFIG.public_group_id;
const CHAT_CLEAR_MESSAGE = CHAT_CONFIG.system_messages_keys.chat_clear;
if (chatId) {
2019-02-15 04:18:06 +08:00
GroupChatMsg.remove({ meetingId, chatId }, () => {
Logger.info(`Cleared GroupChatMsg (${meetingId}, ${chatId})`);
const clearMsg = {
color: '0',
timestamp: Date.now(),
correlationId: `${PUBLIC_CHAT_SYSTEM_ID}-${Date.now()}`,
sender: {
id: PUBLIC_CHAT_SYSTEM_ID,
name: '',
},
message: CHAT_CLEAR_MESSAGE,
};
addGroupChatMsg(meetingId, PUBLIC_GROUP_CHAT_ID, clearMsg);
});
return true;
}
if (meetingId) {
2020-07-15 03:51:06 +08:00
return GroupChatMsg.remove({ meetingId }, () => {
Logger.info(`Cleared GroupChatMsg (${meetingId})`);
});
}
2019-02-20 01:51:52 +08:00
return GroupChatMsg.remove({ chatId: { $eq: PUBLIC_GROUP_CHAT_ID } }, () => {
Logger.info('Cleared GroupChatMsg (all)');
});
}