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
|
|
|
|
2023-03-16 21:03:29 +08:00
|
|
|
export default async function removeGroupChat(meetingId, chatId) {
|
2018-03-10 02:42:14 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(chatId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
chatId,
|
|
|
|
meetingId,
|
|
|
|
};
|
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
try {
|
2023-03-16 21:03:29 +08:00
|
|
|
const numberAffected = await GroupChat.removeAsync(selector);
|
2018-03-10 02:42:14 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
if (numberAffected) {
|
2018-03-10 02:42:14 +08:00
|
|
|
Logger.info(`Removed group-chat id=${chatId} meeting=${meetingId}`);
|
|
|
|
clearGroupChatMsg(meetingId, chatId);
|
|
|
|
}
|
2020-11-25 04:44:13 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Removing group-chat from collection: ${err}`);
|
|
|
|
}
|
2018-03-10 02:42:14 +08:00
|
|
|
}
|