Переглянути джерело

Support "/attachments.add"

Shun Miyazawa 3 роки тому
батько
коміт
bf16cec06e

+ 3 - 0
packages/app/src/interfaces/activity.ts

@@ -45,6 +45,7 @@ const ACTION_SHARE_LINK_CREATE = 'SHARE_LINK_CREATE';
 const ACTION_SHARE_LINK_DELETE = 'SHARE_LINK_DELETE';
 const ACTION_SHARE_LINK_DELETE = 'SHARE_LINK_DELETE';
 const ACTION_SHARE_LINK_DELETE_BY_PAGE = 'SHARE_LINK_DELETE_BY_PAGE';
 const ACTION_SHARE_LINK_DELETE_BY_PAGE = 'SHARE_LINK_DELETE_BY_PAGE';
 const ACTION_SHARE_LINK_ALL_DELETE = 'SHARE_LINK_ALL_DELETE';
 const ACTION_SHARE_LINK_ALL_DELETE = 'SHARE_LINK_ALL_DELETE';
+const ACTION_ATTACHMENT_ADD = 'ATTACHMENT_ADD';
 const ACTION_ADMIN_APP_SETTINGS_UPDATE = 'ADMIN_APP_SETTING_UPDATE';
 const ACTION_ADMIN_APP_SETTINGS_UPDATE = 'ADMIN_APP_SETTING_UPDATE';
 const ACTION_ADMIN_SITE_URL_UPDATE = 'ADMIN_SITE_URL_UPDATE';
 const ACTION_ADMIN_SITE_URL_UPDATE = 'ADMIN_SITE_URL_UPDATE';
 const ACTION_ADMIN_MAIL_SMTP_UPDATE = 'ADMIN_MAIL_SMTP_UPDATE';
 const ACTION_ADMIN_MAIL_SMTP_UPDATE = 'ADMIN_MAIL_SMTP_UPDATE';
@@ -118,6 +119,7 @@ export const SupportedAction = {
   ACTION_SHARE_LINK_DELETE,
   ACTION_SHARE_LINK_DELETE,
   ACTION_SHARE_LINK_DELETE_BY_PAGE,
   ACTION_SHARE_LINK_DELETE_BY_PAGE,
   ACTION_SHARE_LINK_ALL_DELETE,
   ACTION_SHARE_LINK_ALL_DELETE,
+  ACTION_ATTACHMENT_ADD,
   ACTION_ADMIN_APP_SETTINGS_UPDATE,
   ACTION_ADMIN_APP_SETTINGS_UPDATE,
   ACTION_ADMIN_SITE_URL_UPDATE,
   ACTION_ADMIN_SITE_URL_UPDATE,
   ACTION_ADMIN_MAIL_SMTP_UPDATE,
   ACTION_ADMIN_MAIL_SMTP_UPDATE,
@@ -205,6 +207,7 @@ export const MediumActionGroup = {
   ACTION_SHARE_LINK_CREATE,
   ACTION_SHARE_LINK_CREATE,
   ACTION_SHARE_LINK_DELETE,
   ACTION_SHARE_LINK_DELETE,
   ACTION_SHARE_LINK_DELETE_BY_PAGE,
   ACTION_SHARE_LINK_DELETE_BY_PAGE,
+  ACTION_ATTACHMENT_ADD,
 } as const;
 } as const;
 
 
 // MediumActionGroup + All Actions by Admin Users - PAGE_VIEW
 // MediumActionGroup + All Actions by Admin Users - PAGE_VIEW

+ 6 - 0
packages/app/src/server/routes/attachment.js

@@ -1,5 +1,7 @@
+import { SupportedAction } from '~/interfaces/activity';
 import loggerFactory from '~/utils/logger';
 import loggerFactory from '~/utils/logger';
 
 
+
 /* eslint-disable no-use-before-define */
 /* eslint-disable no-use-before-define */
 
 
 
 
@@ -135,6 +137,8 @@ module.exports = function(crowi, app) {
   const GlobalNotificationSetting = crowi.model('GlobalNotificationSetting');
   const GlobalNotificationSetting = crowi.model('GlobalNotificationSetting');
   const { attachmentService, globalNotificationService } = crowi;
   const { attachmentService, globalNotificationService } = crowi;
 
 
+  const activityEvent = crowi.event('activity');
+
   /**
   /**
    * Check the user is accessible to the related page
    * Check the user is accessible to the related page
    *
    *
@@ -472,6 +476,8 @@ module.exports = function(crowi, app) {
       pageCreated,
       pageCreated,
     };
     };
 
 
+    activityEvent.emit('update', res.locals.activity._id, { action: SupportedAction.ACTION_ATTACHMENT_ADD });
+
     res.json(ApiResponse.success(result));
     res.json(ApiResponse.success(result));
 
 
     if (pageCreated) {
     if (pageCreated) {

+ 1 - 1
packages/app/src/server/routes/index.js

@@ -190,7 +190,7 @@ module.exports = function(crowi, app) {
   apiV1Router.post('/comments.update'    , comment.api.validators.add(), accessTokenParser , loginRequiredStrictly , csrf, addActivity, comment.api.update);
   apiV1Router.post('/comments.update'    , comment.api.validators.add(), accessTokenParser , loginRequiredStrictly , csrf, addActivity, comment.api.update);
   apiV1Router.post('/comments.remove'    , accessTokenParser , loginRequiredStrictly , csrf, addActivity, comment.api.remove);
   apiV1Router.post('/comments.remove'    , accessTokenParser , loginRequiredStrictly , csrf, addActivity, comment.api.remove);
 
 
-  apiV1Router.post('/attachments.add'                  , uploads.single('file'), autoReap, accessTokenParser, loginRequiredStrictly ,csrf, attachment.api.add);
+  apiV1Router.post('/attachments.add'                  , uploads.single('file'), autoReap, accessTokenParser, loginRequiredStrictly ,csrf, addActivity ,attachment.api.add);
   apiV1Router.post('/attachments.uploadProfileImage'   , uploads.single('file'), autoReap, accessTokenParser, loginRequiredStrictly ,csrf, attachment.api.uploadProfileImage);
   apiV1Router.post('/attachments.uploadProfileImage'   , uploads.single('file'), autoReap, accessTokenParser, loginRequiredStrictly ,csrf, attachment.api.uploadProfileImage);
   apiV1Router.post('/attachments.remove'               , accessTokenParser , loginRequiredStrictly , csrf, attachment.api.remove);
   apiV1Router.post('/attachments.remove'               , accessTokenParser , loginRequiredStrictly , csrf, attachment.api.remove);
   apiV1Router.post('/attachments.removeProfileImage'   , accessTokenParser , loginRequiredStrictly , csrf, attachment.api.removeProfileImage);
   apiV1Router.post('/attachments.removeProfileImage'   , accessTokenParser , loginRequiredStrictly , csrf, attachment.api.removeProfileImage);