Skip to content
Snippets Groups Projects
Commit bbd228a6 authored by Aaron Ogle's avatar Aaron Ogle
Browse files

Allow actionLinks server side as well as client side

parent 07eb9f35
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@ Package.onUse(function(api) {
api.addAssets('client/stylesheets/actionLinks.less', 'server');
api.addFiles('loadStylesheets.js', 'server');
api.addFiles('server/registerActionLinkFuncts.js', 'server');
api.addFiles('server/actionLinkHandler.js', 'server');
api.addFiles('server/registerActionLinkFuncts.js', ['server', 'client']);
api.addFiles('server/actionLinkHandler.js', ['server', 'client']);
});
......@@ -6,7 +6,7 @@ Meteor.methods({
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'actionLinkHandler' });
}
var message = RocketChat.models.Messages.findOneById(messageId);
var message = RocketChat.models.Messages.findOne({ _id: messageId });
if (!message) {
throw new Meteor.Error('error-invalid-message', 'Invalid message', { method: 'actionLinkHandler' });
}
......@@ -16,7 +16,8 @@ Meteor.methods({
throw new Meteor.Error('error-invalid-actionlink', 'Invalid action link', { method: 'actionLinkHandler' });
}
if (!Meteor.call('canAccessRoom', message.rid, Meteor.userId())) {
var room = RocketChat.models.Rooms.findOne({ _id: message.rid });
if (Array.isArray(room.usernames) && room.usernames.indexOf(Meteor.user().username) === -1) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'actionLinkHandler' });
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment