mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
#6870 asks for a site-wide switch that turns attachments off, because the per-board allowsAttachments flag has to be set on every board. That switch is there already: Admin Panel / Attachments / Transfer limits, "Attachments upload" and "API upload" set to Blocked, and the server refuses on every path - the upload pipeline, api.attachment.upload and .copy, and the /api/attachment upload, upload-background and copy routes. What was missing is that the card still showed the "+" button and accepted a drop for an upload that would be refused. attachmentUploadPolicy tells a signed-in client the one boolean (nothing about the limits), asked at most once a minute, and the "+" and the drop/paste upload follow it. No second setting is added, so there is nothing that could disagree with what the server enforces. tests/attachmentUploadPolicy.test.cjs pins the client, the method, and the server enforcement it relies on, and that no "disableAttachments" setting exists. Thanks to Raymond-Voogt and xet7 ! Refs #6870, not closed: the reporter asked for a single Features checkbox, and the two Blocked limits are two settings.
26 lines
1.2 KiB
JavaScript
26 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
// Whether this installation lets people upload attachments (#6870).
|
|
//
|
|
// The switch already exists: Admin Panel / Attachments / Transfer limits has "Attachments upload"
|
|
// and "API upload" set to Blocked (limitSettings.attachmentsUploadBlocked / apiUploadBlocked).
|
|
// The server refuses an upload on every path when it is on - the upload pipeline
|
|
// (models/attachments.server.js) and the API methods and routes (server/attachmentApi.js,
|
|
// server/routes/attachmentApi.js). What was missing is that the card still offered the "+" button
|
|
// and a drop zone for an upload that would be refused. This is the one decision the server
|
|
// method that tells the client and the tests share, so there is no second setting that could
|
|
// disagree with the one the server enforces.
|
|
//
|
|
// Only the boolean leaves the server: the rest of the limits (sizes, storage paths) are for
|
|
// administrators.
|
|
|
|
function uploadPolicy(limitSettings) {
|
|
const limits = limitSettings && typeof limitSettings === 'object' ? limitSettings : {};
|
|
return {
|
|
// anything but a real `true` keeps uploads as they were
|
|
uploadsBlocked: limits.attachmentsUploadBlocked === true,
|
|
};
|
|
}
|
|
|
|
module.exports = { uploadPolicy };
|