Adjusted permissions for the multi-user cursorMove
This commit is contained in:
parent
f90a1d446f
commit
cd4150ebf5
@ -1,7 +1,6 @@
|
|||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import mapToAcl from '/imports/startup/mapToAcl';
|
|
||||||
import publishCursorUpdate from './methods/publishCursorUpdate';
|
import publishCursorUpdate from './methods/publishCursorUpdate';
|
||||||
|
|
||||||
Meteor.methods(mapToAcl(['methods.moveCursor'], {
|
Meteor.methods({
|
||||||
publishCursorUpdate,
|
publishCursorUpdate,
|
||||||
}));
|
});
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
import { getMultiUserStatus } from '/imports/api/common/server/helpers';
|
||||||
import RedisPubSub from '/imports/startup/server/redis2x';
|
import RedisPubSub from '/imports/startup/server/redis2x';
|
||||||
|
import Acl from '/imports/startup/acl';
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { check } from 'meteor/check';
|
import { check } from 'meteor/check';
|
||||||
|
|
||||||
|
|
||||||
export default function publishCursorUpdate(credentials, coordinates) {
|
export default function publishCursorUpdate(credentials, coordinates) {
|
||||||
const REDIS_CONFIG = Meteor.settings.redis;
|
const REDIS_CONFIG = Meteor.settings.redis;
|
||||||
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
||||||
@ -17,6 +20,7 @@ export default function publishCursorUpdate(credentials, coordinates) {
|
|||||||
yPercent: Number,
|
yPercent: Number,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (Acl.can('methods.moveCursor', credentials) || getMultiUserStatus(meetingId)) {
|
||||||
const header = {
|
const header = {
|
||||||
name: EVENT_NAME,
|
name: EVENT_NAME,
|
||||||
userId: requesterUserId,
|
userId: requesterUserId,
|
||||||
@ -29,4 +33,8 @@ export default function publishCursorUpdate(credentials, coordinates) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return RedisPubSub.publish(CHANNEL, EVENT_NAME, meetingId, payload, header);
|
return RedisPubSub.publish(CHANNEL, EVENT_NAME, meetingId, payload, header);
|
||||||
|
}
|
||||||
|
throw new Meteor.Error(
|
||||||
|
'not-allowed', `User ${requesterUserId} is not allowed to move the cursor`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import { logger } from '/imports/startup/server/logger';
|
|
||||||
import { redisPubSub } from '/imports/startup/server';
|
import { redisPubSub } from '/imports/startup/server';
|
||||||
import { BREAK_LINE, CARRIAGE_RETURN, NEW_LINE } from '/imports/utils/lineEndings.js';
|
import { BREAK_LINE, CARRIAGE_RETURN, NEW_LINE } from '/imports/utils/lineEndings';
|
||||||
|
import WhiteboardMultiUser from '/imports/api/2.0/whiteboard-multi-user/';
|
||||||
|
|
||||||
export function appendMessageHeader(eventName, messageObj) {
|
export function appendMessageHeader(eventName, messageObj) {
|
||||||
let header;
|
const header = {
|
||||||
header = {
|
|
||||||
timestamp: new Date().getTime(),
|
timestamp: new Date().getTime(),
|
||||||
name: eventName,
|
name: eventName,
|
||||||
};
|
};
|
||||||
@ -13,7 +12,7 @@ export function appendMessageHeader(eventName, messageObj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const indexOf = [].indexOf || function (item) {
|
export const indexOf = [].indexOf || function (item) {
|
||||||
for (let i = 0, l = this.length; i < l; i++) {
|
for (let i = 0, l = this.length; i < l; i += 1) {
|
||||||
if (i in this && this[i] === item) {
|
if (i in this && this[i] === item) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -38,3 +37,13 @@ export const translateHTML5ToFlash = function (message) {
|
|||||||
export const inReplyToHTML5Client = function (arg) {
|
export const inReplyToHTML5Client = function (arg) {
|
||||||
return arg.routing.userId === 'nodeJSapp';
|
return arg.routing.userId === 'nodeJSapp';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getMultiUserStatus = (meetingId) => {
|
||||||
|
const data = WhiteboardMultiUser.findOne({ meetingId });
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
return data.multiUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user