Added rate limiting to heavy subscriptions
This commit is contained in:
@@ -52,3 +52,4 @@ ongoworks:speakingurl
|
||||
service-configuration@1.0.11
|
||||
google-config-ui
|
||||
dynamic-import
|
||||
ddp-rate-limiter
|
||||
|
||||
@@ -185,6 +185,7 @@ Schemas.Character = new SimpleSchema({
|
||||
type: String,
|
||||
defaultValue: "whitelist",
|
||||
allowedValues: ["whitelist", "public"],
|
||||
index: 1,
|
||||
},
|
||||
"settings.swapStatAndModifier": {type: Boolean, defaultValue: false},
|
||||
"settings.exportFeatures": {type: Boolean, defaultValue: true},
|
||||
|
||||
@@ -25,3 +25,10 @@ Meteor.publish("characterList", function(){
|
||||
Parties.find({owner: userId}),
|
||||
];
|
||||
});
|
||||
|
||||
DDPRateLimiter.addRule({
|
||||
name: "characterList",
|
||||
type: "subscription",
|
||||
userId(){ return true; },
|
||||
connectionId(){ return true; },
|
||||
}, 8, 5000);
|
||||
|
||||
@@ -35,9 +35,16 @@ Meteor.publish("singleCharacter", function(characterId){
|
||||
}
|
||||
});
|
||||
|
||||
DDPRateLimiter.addRule({
|
||||
name: "singleCharacter",
|
||||
type: "subscription",
|
||||
userId(){ return true; },
|
||||
connectionId(){ return true; },
|
||||
}, 8, 5000);
|
||||
|
||||
Meteor.publish("singleCharacterName", function(characterId){
|
||||
userId = this.userId;
|
||||
var char = Characters.findOne({
|
||||
return Characters.find({
|
||||
_id: characterId,
|
||||
$or: [
|
||||
{readers: userId},
|
||||
@@ -45,8 +52,7 @@ Meteor.publish("singleCharacterName", function(characterId){
|
||||
{owner: userId},
|
||||
{"settings.viewPermission": "public"},
|
||||
],
|
||||
}, {
|
||||
fields:{"name": 1}
|
||||
});
|
||||
if (char) {
|
||||
return Characters.find(characterId, {fields:{"name": 1}});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user