2018-03-10 02:42:14 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import GroupChat from '/imports/api/group-chat';
|
2018-08-06 20:05:07 +08:00
|
|
|
import clearGroupChatMsg from '/imports/api/group-chat-msg/server/modifiers/clearGroupChatMsg';
|
2018-03-10 02:42:14 +08:00
|
|
|
|
|
|
|
export default function removeGroupChat(meetingId, chatId) {
|
|
|
|
check(meetingId, String);
|
|
|
|
check(chatId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
chatId,
|
|
|
|
meetingId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const cb = (err, numChanged) => {
|
|
|
|
if (err) {
|
|
|
|
Logger.error(`Removing group-chat from collection: ${err}`);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numChanged) {
|
|
|
|
// TODO: Clear group-chat-messages
|
|
|
|
Logger.info(`Removed group-chat id=${chatId} meeting=${meetingId}`);
|
|
|
|
clearGroupChatMsg(meetingId, chatId);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return GroupChat.remove(selector, cb);
|
|
|
|
}
|