Skip to content
Snippets Groups Projects
Commit 3528be6b authored by Gabriel Engel's avatar Gabriel Engel
Browse files

Merge pull request #2806 from RocketChat/fix-invite-non-public-rooms

Clear stream read permission cache on subscribe
parents ab788d5f bb7c46ed
No related merge requests found
......@@ -11,6 +11,13 @@ Meteor.Stream = function Stream(name, callback) {
var pendingEvents = [];
self._emit = self.emit;
self._on = self.on;
self.on = function on() {
self._on.apply(this, arguments);
var context = { subscriptionId: subscriptionId };
self.emit.call(context, 'clear', arguments);
};
collection.find({}).observe({
"added": function(item) {
......
......@@ -78,6 +78,10 @@ Meteor.Stream = function Stream(name) {
methodContext.userId = userId;
methodContext.subscriptionId = subscriptionId;
if (args[0] === 'clear') {
return self.permissions.clearCache(subscriptionId, args[1]);
}
//in order to send this to the serve callback
methodContext.allowed = self.permissions.checkPermission('write', subscriptionId, methodContext.userId, args);
if(methodContext.allowed) {
......
......@@ -8,6 +8,11 @@ Meteor.Stream.Permission = function (acceptAll, cacheAll) {
}
};
this.clearCache = function(subscriptionId, args) {
var eventName = args[0];
delete options['read'].results[subscriptionId + '-' + eventName];
};
this.read = function(func, cache) {
options['read']['func'] = func;
options['read']['doCache'] = (cache === undefined)? cacheAll: cache;
......
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