|
@@ -309,89 +309,5 @@ module.exports = (crowi) => {
|
|
|
},
|
|
},
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @swagger
|
|
|
|
|
- *
|
|
|
|
|
- * paths:
|
|
|
|
|
- * /content-disposition-settings/{mimeType}:
|
|
|
|
|
- * put:
|
|
|
|
|
- * tags: [Content Disposition Settings]
|
|
|
|
|
- * summary: Update content disposition setting for a specific MIME type
|
|
|
|
|
- * security:
|
|
|
|
|
- * - cookieAuth: []
|
|
|
|
|
- * parameters:
|
|
|
|
|
- * - $ref: '#/components/parameters/MimeTypePathParam'
|
|
|
|
|
- * requestBody:
|
|
|
|
|
- * required: true
|
|
|
|
|
- * content:
|
|
|
|
|
- * application/json:
|
|
|
|
|
- * schema:
|
|
|
|
|
- * type: object
|
|
|
|
|
- * required:
|
|
|
|
|
- * - disposition
|
|
|
|
|
- * properties:
|
|
|
|
|
- * disposition:
|
|
|
|
|
- * type: string
|
|
|
|
|
- * responses:
|
|
|
|
|
- * 200:
|
|
|
|
|
- * description: Successfully updated content disposition setting
|
|
|
|
|
- * content:
|
|
|
|
|
- * application/json:
|
|
|
|
|
- * schema:
|
|
|
|
|
- * type: object
|
|
|
|
|
- * properties:
|
|
|
|
|
- * setting:
|
|
|
|
|
- * type: object
|
|
|
|
|
- * properties:
|
|
|
|
|
- * mimeType:
|
|
|
|
|
- * type: string
|
|
|
|
|
- * disposition:
|
|
|
|
|
- * type: string
|
|
|
|
|
- */
|
|
|
|
|
- router.put(
|
|
|
|
|
- '/:mimeType(*)',
|
|
|
|
|
- loginRequiredStrictly,
|
|
|
|
|
- adminRequired,
|
|
|
|
|
- addActivity,
|
|
|
|
|
- validator.updateContentDisposition,
|
|
|
|
|
- apiV3FormValidator,
|
|
|
|
|
- async(req, res) => {
|
|
|
|
|
- const { mimeType } = req.params;
|
|
|
|
|
- const { disposition } = req.body;
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- const currentMimeTypeDefaults = configManager.getConfig('attachments:contentDisposition:mimeTypeOverrides');
|
|
|
|
|
-
|
|
|
|
|
- const newDisposition: 'inline' | 'attachment' = disposition;
|
|
|
|
|
-
|
|
|
|
|
- const updatedMimeTypeDefaults = {
|
|
|
|
|
- ...currentMimeTypeDefaults,
|
|
|
|
|
- [mimeType]: newDisposition,
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- await configManager.updateConfigs({ 'attachments:contentDisposition:mimeTypeOverrides': updatedMimeTypeDefaults });
|
|
|
|
|
- const updatedDispositionFromDb = configManager.getConfig('attachments:contentDisposition:mimeTypeOverrides')[mimeType];
|
|
|
|
|
-
|
|
|
|
|
- const parameters = {
|
|
|
|
|
- action: SupportedAction.ACTION_ADMIN_ATTACHMENT_DISPOSITION_UPDATE,
|
|
|
|
|
- mimeType,
|
|
|
|
|
- disposition: updatedDispositionFromDb,
|
|
|
|
|
- };
|
|
|
|
|
- activityEvent.emit('update', res.locals.activity._id, parameters);
|
|
|
|
|
-
|
|
|
|
|
- return res.apiv3({ mimeType, disposition: updatedDispositionFromDb });
|
|
|
|
|
- }
|
|
|
|
|
- catch (err) {
|
|
|
|
|
- const msg = `Error occurred in updating content disposition for MIME type: ${mimeType}`;
|
|
|
|
|
- logger.error(msg, err);
|
|
|
|
|
- return res.apiv3Err(
|
|
|
|
|
- new ErrorV3(msg, 'update-content-disposition-failed'),
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
return router;
|
|
return router;
|
|
|
};
|
|
};
|