diff --git a/lib/directive.js b/lib/directive.js index 1985a1a..cbef75a 100644 --- a/lib/directive.js +++ b/lib/directive.js @@ -78,7 +78,7 @@ Slingshot.createDirective = function (name, service, options) { _.defaults(options, restrictions); return (Slingshot._directives[name] = - new Slingshot.Directive(name, service, options)); + new Slingshot.Directive(service, options)); }; /** @@ -97,11 +97,9 @@ Slingshot.getDirective = function (name) { * @constructor */ -Slingshot.Directive = function (name, service, directive) { +Slingshot.Directive = function (service, directive) { check(this, Slingshot.Directive); - check(name, String); - //service does not have to be a plain-object, so checking fields individually check(service.directiveMatch, Object); check(service.upload, Function); @@ -118,12 +116,6 @@ Slingshot.Directive = function (name, service, directive) { contentDisposition: Match.Optional(Match.OneOf(String, null)) }, service.directiveMatch)); - /** - * @public - * @property {String} The directive name - */ - this.name = name; - /** * @method storageService * @returns {Object} @@ -174,8 +166,10 @@ _.extend(Slingshot.Directive.prototype, mixins, { */ getRestriction: function (restriction) { - return Slingshot.getRestrictions(this.name)[restriction] || - this._directive[restriction]; + var restrictions = _.pick(this._directive, + ['authorize', 'maxSize', 'allowedFileTypes'] + ); + return restrictions[restriction]; } }); diff --git a/lib/restrictions.js b/lib/restrictions.js index 6299f0d..d773247 100644 --- a/lib/restrictions.js +++ b/lib/restrictions.js @@ -31,6 +31,13 @@ Slingshot.fileRestrictions = function (name, restrictions) { allowedFileTypes: Match.Optional(matchAllowedFileTypes), }); + if (Meteor.isServer) { + var directive = Slingshot.getDirective(name); + if (directive) { + _.extend(directive._directive, restrictions); + } + } + return (Slingshot._restrictions[name] = _.extend(Slingshot._restrictions[name] || {}, restrictions)); }; diff --git a/lib/upload.js b/lib/upload.js index d657aa3..e611d13 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -114,7 +114,7 @@ Slingshot.Upload = function (directive, metaData) { var file = _.pick(self.file, "name", "size", "type"); - status.set("authorizing"); + status.set("validating"); var valid = this.validate(file); if (valid !== true) {