remove use of soon-to-be-deprecated 'Discourse.SiteSettings' (cc @eviltrout)
This commit is contained in:
parent
485de2fcc3
commit
f943efe1a9
|
@ -240,7 +240,11 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
$element.on('fileuploadsubmit', (e, data) => {
|
$element.on('fileuploadsubmit', (e, data) => {
|
||||||
const isPrivateMessage = this.get("composer.privateMessage");
|
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 };
|
data.formData = { type: "composer", for_private_message: isPrivateMessage };
|
||||||
this.setProperties({ uploadProgress: 0, isUploading });
|
this.setProperties({ uploadProgress: 0, isUploading });
|
||||||
return isUploading;
|
return isUploading;
|
||||||
|
|
|
@ -185,8 +185,8 @@ export function validateUploadedFile(file, opts) {
|
||||||
if (!name) { return false; }
|
if (!name) { return false; }
|
||||||
|
|
||||||
// check that the uploaded file is authorized
|
// check that the uploaded file is authorized
|
||||||
if (Discourse.SiteSettings.allow_staff_to_upload_any_file_in_pm) {
|
if (opts["allowStaffToUploadAnyFileInPm"] && opts["isPrivateMessage"]) {
|
||||||
if (opts["isPrivateMessage"] && Discourse.User.current("staff")) {
|
if (Discourse.User.current("staff")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,14 +73,12 @@ test("ensures an authorized upload", function() {
|
||||||
test("staff can upload anything in PM", function() {
|
test("staff can upload anything in PM", function() {
|
||||||
const files = [{ name: "some.docx" }];
|
const files = [{ name: "some.docx" }];
|
||||||
Discourse.SiteSettings.authorized_extensions = "jpeg";
|
Discourse.SiteSettings.authorized_extensions = "jpeg";
|
||||||
Discourse.SiteSettings.allow_staff_to_upload_any_file_in_pm = true;
|
|
||||||
|
|
||||||
Discourse.User.resetCurrent(Discourse.User.create({ moderator: true }));
|
Discourse.User.resetCurrent(Discourse.User.create({ moderator: true }));
|
||||||
|
|
||||||
sandbox.stub(bootbox, "alert");
|
sandbox.stub(bootbox, "alert");
|
||||||
|
|
||||||
not(validUpload(files));
|
not(validUpload(files));
|
||||||
ok(validUpload(files, { isPrivateMessage: true }));
|
ok(validUpload(files, { isPrivateMessage: true, allowStaffToUploadAnyFileInPm: true }));
|
||||||
});
|
});
|
||||||
|
|
||||||
var imageSize = 10 * 1024;
|
var imageSize = 10 * 1024;
|
||||||
|
|
Loading…
Reference in New Issue