bigbluebutton-Github/bigbluebutton-html5/imports/api/1.1/chat/server/publishers.js

42 lines
1.0 KiB
JavaScript
Raw Normal View History

2017-06-19 19:57:32 +08:00
import Chat from '/imports/api/1.1/chat';
2016-10-19 20:18:47 +08:00
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
2017-06-01 01:54:43 +08:00
import mapToAcl from '/imports/startup/mapToAcl';
2016-10-19 20:18:47 +08:00
2017-06-01 01:54:43 +08:00
function chat(credentials) {
const CHAT_CONFIG = Meteor.settings.public.chat;
const PUBLIC_CHAT_TYPE = CHAT_CONFIG.type_public;
2016-10-19 20:18:47 +08:00
const { meetingId, requesterUserId, requesterToken } = credentials;
check(meetingId, String);
check(requesterUserId, String);
check(requesterToken, String);
Logger.info(`Publishing chat for ${meetingId} ${requesterUserId} ${requesterToken}`);
return Chat.find({
$or: [
{
'message.chat_type': PUBLIC_CHAT_TYPE,
meetingId,
2016-10-19 20:18:47 +08:00
}, {
'message.from_userid': requesterUserId,
meetingId,
2016-10-19 20:18:47 +08:00
}, {
'message.to_userid': requesterUserId,
meetingId,
2016-10-19 20:18:47 +08:00
},
],
});
2017-06-06 03:12:06 +08:00
}
function publish(...args) {
const boundChat = chat.bind(this);
return mapToAcl('subscriptions.chat', boundChat)(args);
}
Meteor.publish('chat', publish);