Просмотр исходного кода

Remove attachmentType from request body

https://youtrack.weseek.co.jp/issue/GW-7759
- Remove attachmentType from request body in AdminCustomizeContainer
- Remove AttachmentType import in AdminCustomizeContainer
- Remove unused constant of `currentUser` from GrowiNavbar
- Adjust AttachmentType params in createAttachment for upload Logo and profile image
mudana 3 лет назад
Родитель
Сommit
4b84ecffed

+ 0 - 2
packages/app/src/client/services/AdminCustomizeContainer.js

@@ -1,6 +1,5 @@
 import { Container } from 'unstated';
 
-import { AttachmentType } from '~/server/interfaces/attachment';
 import loggerFactory from '~/utils/logger';
 
 import { toastError } from '../util/apiNotification';
@@ -465,7 +464,6 @@ export default class AdminCustomizeContainer extends Container {
     try {
       const formData = new FormData();
       formData.append('file', file);
-      formData.append('attachmentType', AttachmentType.BRAND_LOGO);
       formData.append('brandLogoAttachmentId', this.state.brandLogoAttachmentId);
       const response = await apiPostForm('/attachments.uploadBrandLogo', formData);
 

+ 0 - 1
packages/app/src/components/Navbar/GrowiNavbar.tsx

@@ -121,7 +121,6 @@ const GrowiNavbarLogo: FC<NavbarLogoProps> = memo((props: NavbarLogoProps) => {
 const GrowiNavbar = (props) => {
 
   const { appContainer } = props;
-  const { currentUser } = appContainer;
   const {
     crowi, isSearchServiceConfigured, uploadedLogoSrc, isDefaultLogo,
   } = appContainer.config;

+ 4 - 4
packages/app/src/server/routes/attachment.js

@@ -557,7 +557,7 @@ module.exports = function(crowi, app) {
     }
 
     const file = req.file;
-    const attachmentType = req.body.attachmentType;
+
     // check type
     const acceptableFileType = /image\/.+/;
     if (!file.mimetype.match(acceptableFileType)) {
@@ -567,7 +567,7 @@ module.exports = function(crowi, app) {
     let attachment;
     try {
       req.user.deleteImage();
-      attachment = await attachmentService.createAttachment(file, req.user, null, attachmentType);
+      attachment = await attachmentService.createAttachment(file, req.user, null, AttachmentType.PROFILE_IMAGE);
       await req.user.updateImage(attachment);
     }
     catch (err) {
@@ -716,7 +716,7 @@ module.exports = function(crowi, app) {
     }
 
     const file = req.file;
-    const { attachmentType, brandLogoAttachmentId } = req.body;
+    const { brandLogoAttachmentId } = req.body;
 
     let previousAttachmentId;
     if (brandLogoAttachmentId === 'null' || brandLogoAttachmentId === 'undefined') {
@@ -740,7 +740,7 @@ module.exports = function(crowi, app) {
 
     let attachment;
     try {
-      attachment = await attachmentService.createAttachment(file, req.user, null, attachmentType);
+      attachment = await attachmentService.createAttachment(file, req.user, null, AttachmentType.BRAND_LOGO);
       const attachmentConfigParams = {
         'customize:brandLogoAttachmentId': attachment.id,
         'customize:uploadedLogoSrc': attachment.filePathProxied,