bigbluebutton-Github/bigbluebutton-html5/imports/api/chat/server/handlers/chatHistory.js
2016-10-21 11:56:03 +00:00

25 lines
618 B
JavaScript

import Logger from '/imports/startup/server/logger';
import { check } from 'meteor/check';
import { inReplyToHTML5Client } from '/imports/api/common/server/helpers';
import addChat from '../modifiers/addChat';
export default function handleChatHistory({ payload }) {
if (!inReplyToHTML5Client({ payload })) {
return;
}
const meetingId = payload.meeting_id;
const chatHistory = payload.chat_history || [];
check(meetingId, String);
check(chatHistory, Array);
let chatsAdded = [];
chatHistory.forEach(message => {
chatsAdded.push(addChat(meetingId, message));
});
return chatsAdded;
};