From f943efe1a9279ac796d349a2ee5d64829103e6ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 14 Jun 2017 10:02:13 +0200 Subject: [PATCH] remove use of soon-to-be-deprecated 'Discourse.SiteSettings' (cc @eviltrout) --- .../javascripts/discourse/components/composer-editor.js.es6 | 6 +++++- app/assets/javascripts/discourse/lib/utilities.js.es6 | 4 ++-- test/javascripts/lib/utilities-test.js.es6 | 4 +--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/components/composer-editor.js.es6 b/app/assets/javascripts/discourse/components/composer-editor.js.es6 index b978272f703..f3a0b790e04 100644 --- a/app/assets/javascripts/discourse/components/composer-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/composer-editor.js.es6 @@ -240,7 +240,11 @@ export default Ember.Component.extend({ $element.on('fileuploadsubmit', (e, data) => { const isPrivateMessage = this.get("composer.privateMessage"); - const isUploading = validateUploadedFiles(data.files, { isPrivateMessage }); + const opts = { + isPrivateMessage, + allowStaffToUploadAnyFileInPm: this.siteSettings.allow_staff_to_upload_any_file_in_pm, + } + const isUploading = validateUploadedFiles(data.files, opts); data.formData = { type: "composer", for_private_message: isPrivateMessage }; this.setProperties({ uploadProgress: 0, isUploading }); return isUploading; diff --git a/app/assets/javascripts/discourse/lib/utilities.js.es6 b/app/assets/javascripts/discourse/lib/utilities.js.es6 index 98b7a974fd0..5dca7f9942b 100644 --- a/app/assets/javascripts/discourse/lib/utilities.js.es6 +++ b/app/assets/javascripts/discourse/lib/utilities.js.es6 @@ -185,8 +185,8 @@ export function validateUploadedFile(file, opts) { if (!name) { return false; } // check that the uploaded file is authorized - if (Discourse.SiteSettings.allow_staff_to_upload_any_file_in_pm) { - if (opts["isPrivateMessage"] && Discourse.User.current("staff")) { + if (opts["allowStaffToUploadAnyFileInPm"] && opts["isPrivateMessage"]) { + if (Discourse.User.current("staff")) { return true; } } diff --git a/test/javascripts/lib/utilities-test.js.es6 b/test/javascripts/lib/utilities-test.js.es6 index 796c1afb396..7c4e000bbe8 100644 --- a/test/javascripts/lib/utilities-test.js.es6 +++ b/test/javascripts/lib/utilities-test.js.es6 @@ -73,14 +73,12 @@ test("ensures an authorized upload", function() { test("staff can upload anything in PM", function() { const files = [{ name: "some.docx" }]; Discourse.SiteSettings.authorized_extensions = "jpeg"; - Discourse.SiteSettings.allow_staff_to_upload_any_file_in_pm = true; - Discourse.User.resetCurrent(Discourse.User.create({ moderator: true })); sandbox.stub(bootbox, "alert"); not(validUpload(files)); - ok(validUpload(files, { isPrivateMessage: true })); + ok(validUpload(files, { isPrivateMessage: true, allowStaffToUploadAnyFileInPm: true })); }); var imageSize = 10 * 1024;