bigbluebutton-Github/bigbluebutton-html5/imports/api/2.0/chat/server/publishers.js
2017-07-12 17:15:50 -03:00

41 lines
1.0 KiB
JavaScript

import Chat from '/imports/api/2.0/chat';
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import mapToAcl from '/imports/startup/mapToAcl';
function chat(credentials) {
const { meetingId, requesterUserId, requesterToken } = credentials;
check(meetingId, String);
check(requesterUserId, String);
check(requesterToken, String);
const CHAT_CONFIG = Meteor.settings.public.chat;
const PUBLIC_CHAT_USERNAME = CHAT_CONFIG.public_username;
Logger.info(`Publishing chat for ${meetingId} ${requesterUserId} ${requesterToken}`);
return Chat.find({
$or: [
{
'message.toUsername': PUBLIC_CHAT_USERNAME,
meetingId,
}, {
'message.fromUserId': requesterUserId,
meetingId,
}, {
'message.toUserId': requesterUserId,
meetingId,
},
],
});
}
function publish(...args) {
const boundChat = chat.bind(this);
return mapToAcl('subscriptions.chat', boundChat)(args);
}
Meteor.publish('chat2x', publish);