Merge pull request #9782 from jfsiebel/resubscribe-when-role-changed

Subscribe to collections when user role change
This commit is contained in:
Anton Georgiev 2020-06-05 12:49:41 -04:00 committed by GitHub
commit 8c077aaf63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 9 deletions

View File

@ -6,7 +6,7 @@ import { extractCredentials } from '/imports/api/common/server/helpers';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator; const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
function breakouts() { function breakouts(role) {
if (!this.userId) { if (!this.userId) {
return Breakouts.find({ meetingId: '' }); return Breakouts.find({ meetingId: '' });
} }

View File

@ -6,7 +6,7 @@ import { extractCredentials } from '/imports/api/common/server/helpers';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator; const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
function meetings() { function meetings(role) {
if (!this.userId) { if (!this.userId) {
return Meetings.find({ meetingId: '' }); return Meetings.find({ meetingId: '' });
} }

View File

@ -51,7 +51,7 @@ function publishCurrentUser(...args) {
Meteor.publish('current-user', publishCurrentUser); Meteor.publish('current-user', publishCurrentUser);
function users() { function users(role) {
if (!this.userId) { if (!this.userId) {
return Users.find({ meetingId: '' }); return Users.find({ meetingId: '' });
} }

View File

@ -4,6 +4,7 @@ import Auth from '/imports/ui/services/auth';
import logger from '/imports/startup/client/logger'; import logger from '/imports/startup/client/logger';
import GroupChat from '/imports/api/group-chat'; import GroupChat from '/imports/api/group-chat';
import Annotations from '/imports/api/annotations'; import Annotations from '/imports/api/annotations';
import Users from '/imports/api/users';
import AnnotationsTextService from '/imports/ui/components/whiteboard/annotations/text/service'; import AnnotationsTextService from '/imports/ui/components/whiteboard/annotations/text/service';
import AnnotationsLocal from '/imports/ui/components/whiteboard/service'; import AnnotationsLocal from '/imports/ui/components/whiteboard/service';
@ -18,7 +19,7 @@ const SUBSCRIPTIONS = [
'voiceUsers', 'whiteboard-multi-user', 'screenshare', 'group-chat', 'voiceUsers', 'whiteboard-multi-user', 'screenshare', 'group-chat',
'presentation-pods', 'users-settings', 'guestUser', 'users-infos', 'note', 'meeting-time-remaining', 'presentation-pods', 'users-settings', 'guestUser', 'users-infos', 'note', 'meeting-time-remaining',
'network-information', 'ping-pong', 'local-settings', 'users-typing', 'record-meetings', 'video-streams', 'network-information', 'ping-pong', 'local-settings', 'users-typing', 'record-meetings', 'video-streams',
'voice-call-states', 'breakouts', 'voice-call-states',
]; ];
class Subscriptions extends Component { class Subscriptions extends Component {
@ -44,6 +45,8 @@ export default withTracker(() => {
}; };
} }
const currentUser = Users.findOne({ intId: requesterUserId }, { fields: { role: 1 } });
const subscriptionErrorHandler = { const subscriptionErrorHandler = {
onError: (error) => { onError: (error) => {
logger.error({ logger.error({
@ -58,14 +61,16 @@ export default withTracker(() => {
if ((!TYPING_INDICATOR_ENABLED && name.indexOf('typing') !== -1) if ((!TYPING_INDICATOR_ENABLED && name.indexOf('typing') !== -1)
|| (!CHAT_ENABLED && name.indexOf('chat') !== -1)) return; || (!CHAT_ENABLED && name.indexOf('chat') !== -1)) return;
return Meteor.subscribe( return Meteor.subscribe(name, subscriptionErrorHandler);
name,
subscriptionErrorHandler,
);
}); });
if (currentUser) {
subscriptionsHandlers.push(Meteor.subscribe('meetings', currentUser.role, subscriptionErrorHandler));
subscriptionsHandlers.push(Meteor.subscribe('users', currentUser.role, subscriptionErrorHandler));
subscriptionsHandlers.push(Meteor.subscribe('breakouts', currentUser.role, subscriptionErrorHandler));
}
let groupChatMessageHandler = {}; let groupChatMessageHandler = {};
// let annotationsHandler = {};
if (CHAT_ENABLED) { if (CHAT_ENABLED) {
const chats = GroupChat.find({ const chats = GroupChat.find({