فهرست منبع

Merge branch 'feat/growi-bot' into imprv/delete-data-clicked-delete-button

zahmis 4 سال پیش
والد
کامیت
92a20376e7

+ 3 - 3
.github/workflows/ci.yml

@@ -12,9 +12,9 @@ on:
       - .eslint*
       - .eslint*
       - .prettier*
       - .prettier*
       - .stylelint*
       - .stylelint*
-      - config
-      - resource
-      - src
+      - config/**
+      - resource/**
+      - src/**
       - package.json
       - package.json
       - yarn.lock
       - yarn.lock
 
 

+ 3 - 1
resource/locales/en_US/admin/admin.json

@@ -274,6 +274,7 @@
       "impossible": "Impossible"
       "impossible": "Impossible"
     },
     },
     "bot_reset_successful": "Bot settings have been reset.",
     "bot_reset_successful": "Bot settings have been reset.",
+    "bot_all_reset_successful": "All Bot settings have been reset.",
     "copied_to_clipboard": "Copied to clipboard",
     "copied_to_clipboard": "Copied to clipboard",
     "set_scope": "Please set up Bot Token Scopes from Slack settings",
     "set_scope": "Please set up Bot Token Scopes from Slack settings",
     "modal": {
     "modal": {
@@ -308,7 +309,8 @@
       "paste_growi_url": "Enter `http://localhost:3000` for <b>GROWI URL</b>",
       "paste_growi_url": "Enter `http://localhost:3000` for <b>GROWI URL</b>",
       "enter_access_token_for_growi_and_proxy": "Enter <b>Access Token for GROWI</b> and <b>Access Token for Proxy</b>",
       "enter_access_token_for_growi_and_proxy": "Enter <b>Access Token for GROWI</b> and <b>Access Token for Proxy</b>",
       "set_proxy_url_on_growi": "Set Proxy URL on GROWI",
       "set_proxy_url_on_growi": "Set Proxy URL on GROWI",
-      "enter_proxy_url_and_update": "Enter <b>Proxy URL</b> shown on Slack and click Update",
+      "enter_proxy_url_and_update": "1. Enter and update the Proxy URL that you copied in step ③ in the <b>Proxy URL</b>  of the <b>Custom bot with proxy integration</b> on this page.",
+      "dont_need_update": "※If the value is already in there, there is no need to update it.",
       "select_install_your_app": "Select \"Install your app\".",
       "select_install_your_app": "Select \"Install your app\".",
       "select_install_to_workspace": "Select \"Install to Workspace\".",
       "select_install_to_workspace": "Select \"Install to Workspace\".",
       "register_official_bot_proxy_service": "Issue Access Token / Register GROWI Official Bot Proxy Service",
       "register_official_bot_proxy_service": "Issue Access Token / Register GROWI Official Bot Proxy Service",

+ 3 - 1
resource/locales/ja_JP/admin/admin.json

@@ -272,6 +272,7 @@
       "impossible": "不可"
       "impossible": "不可"
     },
     },
     "bot_reset_successful": "Botの設定を消去しました。",
     "bot_reset_successful": "Botの設定を消去しました。",
+    "bot_all_reset_successful": "全ての Bot の設定を消去しました。",
     "copied_to_clipboard": "クリップボードにコピーされました。",
     "copied_to_clipboard": "クリップボードにコピーされました。",
     "set_scope": "Slackの設定画面からBot Token Scopeを設定してください",
     "set_scope": "Slackの設定画面からBot Token Scopeを設定してください",
     "modal": {
     "modal": {
@@ -305,7 +306,8 @@
       "paste_growi_url": "<b>GROWI URL</b>には`http://localhost:3000`を貼り付ける",
       "paste_growi_url": "<b>GROWI URL</b>には`http://localhost:3000`を貼り付ける",
       "enter_access_token_for_growi_and_proxy": "上記で発行した<b>Access Token for GROWI</b> と <b>Access Token for Proxy</b>を入れる",
       "enter_access_token_for_growi_and_proxy": "上記で発行した<b>Access Token for GROWI</b> と <b>Access Token for Proxy</b>を入れる",
       "set_proxy_url_on_growi": "ProxyのURLをGROWIに登録する",
       "set_proxy_url_on_growi": "ProxyのURLをGROWIに登録する",
-      "enter_proxy_url_and_update": "Slack上に通知された<b>Proxy URL</b>を入力し、更新してください。",
+      "enter_proxy_url_and_update": "1. 連携手順③でコピーしたProxy URLを、このページの<b>Custom bot with proxy 連携</b>の<b>Proxy URL</b>に入力、更新します。",
+      "dont_need_update": "※既に値が入っている場合は更新する必要はありません",
       "select_install_your_app": "Install your app をクリックします。",
       "select_install_your_app": "Install your app をクリックします。",
       "select_install_to_workspace": "Install to Workspace をクリックします。",
       "select_install_to_workspace": "Install to Workspace をクリックします。",
       "register_official_bot_proxy_service": "アクセストークンの発行 / GROWI Official Bot Proxy サービスへの登録",
       "register_official_bot_proxy_service": "アクセストークンの発行 / GROWI Official Bot Proxy サービスへの登録",

+ 3 - 1
resource/locales/zh_CN/admin/admin.json

@@ -282,6 +282,7 @@
       "impossible": "不可能"
       "impossible": "不可能"
     },
     },
     "bot_reset_successful": "删除了BOT设置。",
     "bot_reset_successful": "删除了BOT设置。",
+    "bot_all_reset_successful": "所有的 Bot 设置都被清除了。",
     "copied_to_clipboard": "它已复制到剪贴板。",
     "copied_to_clipboard": "它已复制到剪贴板。",
     "set_scope": "在Slack设置页面中配置Bot Token Scope。",
     "set_scope": "在Slack设置页面中配置Bot Token Scope。",
     "modal": {
     "modal": {
@@ -315,7 +316,8 @@
       "paste_growi_url": "将`http://localhost:3000`粘贴到 <b>GROWI URL</b> 网址中",
       "paste_growi_url": "将`http://localhost:3000`粘贴到 <b>GROWI URL</b> 网址中",
       "enter_access_token_for_growi_and_proxy": "插入上面发出的 <b>Access Token for GROWI</b> 和 <b>Access Token for Proxy</b>。",
       "enter_access_token_for_growi_and_proxy": "插入上面发出的 <b>Access Token for GROWI</b> 和 <b>Access Token for Proxy</b>。",
       "set_proxy_url_on_growi": "向GROWI注册Proxy的URL",
       "set_proxy_url_on_growi": "向GROWI注册Proxy的URL",
-      "enter_proxy_url_and_update": "按照Slack上的通知输入并更新你的 <b>Proxy URL</b>。",
+      "enter_proxy_url_and_update": "1. 输入并更新你在步骤③中复制的ProxyURL到本页的<b>Custom bot with proxy 一体化</b>的<b>ProxyURL</b>。",
+      "dont_need_update": "※如果值已经在里面了,就不需要再更新。",
       "select_install_your_app": "选择 \"Install your app\"。",
       "select_install_your_app": "选择 \"Install your app\"。",
       "select_install_to_workspace": "选择 \"Install to Workspace\"。",
       "select_install_to_workspace": "选择 \"Install to Workspace\"。",
       "register_official_bot_proxy_service": "发行访问令牌 / 注册 GROWI 官方 Bot 代理服务",
       "register_official_bot_proxy_service": "发行访问令牌 / 注册 GROWI 官方 Bot 代理服务",

+ 20 - 4
src/client/js/components/Admin/SlackIntegration/CustomBotWithProxySettings.jsx

@@ -2,16 +2,16 @@ import React, { useState } from 'react';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 import AppContainer from '../../../services/AppContainer';
 import AppContainer from '../../../services/AppContainer';
-import AdminAppContainer from '../../../services/AdminAppContainer';
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import { toastSuccess, toastError } from '../../../util/apiNotification';
 import { toastSuccess, toastError } from '../../../util/apiNotification';
 import CustomBotWithProxyIntegrationCard from './CustomBotWithProxyIntegrationCard';
 import CustomBotWithProxyIntegrationCard from './CustomBotWithProxyIntegrationCard';
 import CustomBotWithProxySettingsAccordion from './CustomBotWithProxySettingsAccordion';
 import CustomBotWithProxySettingsAccordion from './CustomBotWithProxySettingsAccordion';
 import DeleteSlackBotSettingsModal from './DeleteSlackBotSettingsModal';
 import DeleteSlackBotSettingsModal from './DeleteSlackBotSettingsModal';
+import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
 
 
 const CustomBotWithProxySettings = (props) => {
 const CustomBotWithProxySettings = (props) => {
   // eslint-disable-next-line no-unused-vars
   // eslint-disable-next-line no-unused-vars
-  const { appContainer, adminAppContainer } = props;
+  const { appContainer } = props;
   const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState(false);
   const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState(false);
 
 
   const { t } = useTranslation();
   const { t } = useTranslation();
@@ -64,6 +64,23 @@ const CustomBotWithProxySettings = (props) => {
         }
         }
         isSlackScopeSet
         isSlackScopeSet
       />
       />
+
+      <div className="form-group row my-4">
+        <label className="text-left text-md-right col-md-3 col-form-label mt-3">Proxy URL</label>
+        <div className="col-md-6 mr-3 mt-3">
+          <input
+            className="form-control"
+            type="text"
+          />
+        </div>
+        <AdminUpdateButtonRow
+          disabled={false}
+          // TODO: Add Proxy URL submit logic
+          // eslint-disable-next-line no-console
+          onClick={() => console.log('Update')}
+        />
+      </div>
+
       <h2 className="admin-setting-header">{t('admin:slack_integration.cooperation_procedure')}</h2>
       <h2 className="admin-setting-header">{t('admin:slack_integration.cooperation_procedure')}</h2>
       <div className="mx-3">
       <div className="mx-3">
 
 
@@ -106,11 +123,10 @@ const CustomBotWithProxySettings = (props) => {
   );
   );
 };
 };
 
 
-const CustomBotWithProxySettingsWrapper = withUnstatedContainers(CustomBotWithProxySettings, [AppContainer, AdminAppContainer]);
+const CustomBotWithProxySettingsWrapper = withUnstatedContainers(CustomBotWithProxySettings, [AppContainer]);
 
 
 CustomBotWithProxySettings.propTypes = {
 CustomBotWithProxySettings.propTypes = {
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
-  adminAppContainer: PropTypes.instanceOf(AdminAppContainer).isRequired,
 };
 };
 
 
 export default CustomBotWithProxySettingsWrapper;
 export default CustomBotWithProxySettingsWrapper;

+ 11 - 21
src/client/js/components/Admin/SlackIntegration/CustomBotWithProxySettingsAccordion.jsx

@@ -1,6 +1,5 @@
 import React, { useState } from 'react';
 import React, { useState } from 'react';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
-import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
 import Accordion from '../Common/Accordion';
 import Accordion from '../Common/Accordion';
 
 
 const CustomBotWithProxySettingsAccordion = () => {
 const CustomBotWithProxySettingsAccordion = () => {
@@ -143,27 +142,18 @@ const CustomBotWithProxySettingsAccordion = () => {
       <Accordion
       <Accordion
         title={<><span className="mr-2">④</span>{t('admin:slack_integration.accordion.set_proxy_url_on_growi')}</>}
         title={<><span className="mr-2">④</span>{t('admin:slack_integration.accordion.set_proxy_url_on_growi')}</>}
       >
       >
-        <div className="p-4">
-          <p
-            className="text-center"
-            // eslint-disable-next-line react/no-danger
-            dangerouslySetInnerHTML={{ __html: t('admin:slack_integration.accordion.enter_proxy_url_and_update') }}
-          />
-          <div className="form-group row my-4">
-            <label className="text-left text-md-right col-md-3 col-form-label">Proxy URL</label>
-            <div className="col-md-6">
-              <input
-                className="form-control"
-                type="text"
-              />
-            </div>
+        <div className="p-4 d-flex flex-column align-items-center">
+          <div>
+            <span
+                // eslint-disable-next-line react/no-danger
+              dangerouslySetInnerHTML={{ __html: t('admin:slack_integration.accordion.enter_proxy_url_and_update') }}
+            />
+            <p className="text-danger">{t('admin:slack_integration.accordion.dont_need_update')}</p>
+          </div>
+          {/* TODO: Insert photo */}
+          <div className="rounded border w-50 d-flex justify-content-center align-items-center" style={{ height: '15rem' }}>
+            <h1 className="text-muted">参考画像</h1>
           </div>
           </div>
-          <AdminUpdateButtonRow
-            disabled={false}
-            // TODO: Add Proxy URL submit logic
-            // eslint-disable-next-line no-console
-            onClick={() => console.log('Update')}
-          />
         </div>
         </div>
       </Accordion>
       </Accordion>
       <Accordion
       <Accordion

+ 13 - 1
src/client/js/components/Admin/SlackIntegration/SlackIntegration.jsx

@@ -28,6 +28,7 @@ const SlackIntegration = (props) => {
   const [slackWSNameInWithoutProxy, setSlackWSNameInWithoutProxy] = useState(null);
   const [slackWSNameInWithoutProxy, setSlackWSNameInWithoutProxy] = useState(null);
   const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState(false);
   const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState(false);
 
 
+
   const fetchSlackIntegrationData = useCallback(async() => {
   const fetchSlackIntegrationData = useCallback(async() => {
     try {
     try {
       const { data } = await appContainer.apiv3.get('/slack-integration-settings');
       const { data } = await appContainer.apiv3.get('/slack-integration-settings');
@@ -51,6 +52,17 @@ const SlackIntegration = (props) => {
     }
     }
   }, [appContainer.apiv3]);
   }, [appContainer.apiv3]);
 
 
+  const resetAllSettings = async() => {
+    try {
+      await appContainer.apiv3.delete('/slack-integration-settings/bot-type');
+      fetchSlackIntegrationData();
+      toastSuccess(t('admin:slack_integration.bot_all_reset_successful'));
+    }
+    catch (error) {
+      toastError(error);
+    }
+  };
+
   const resetWithOutSettings = async() => {
   const resetWithOutSettings = async() => {
     try {
     try {
       await appContainer.apiv3.put('/slack-integration-settings/bot-type', { currentBotType: 'customBotWithoutProxy' });
       await appContainer.apiv3.put('/slack-integration-settings/bot-type', { currentBotType: 'customBotWithoutProxy' });
@@ -137,11 +149,11 @@ const SlackIntegration = (props) => {
         onCancelClick={cancelBotChangeHandler}
         onCancelClick={cancelBotChangeHandler}
       />
       />
 
 
-      {/* TODO add onClickDeleteButton */}
       <DeleteSlackBotSettingsModal
       <DeleteSlackBotSettingsModal
         isResetAll
         isResetAll
         isOpen={isDeleteConfirmModalShown}
         isOpen={isDeleteConfirmModalShown}
         onClose={() => setIsDeleteConfirmModalShown(false)}
         onClose={() => setIsDeleteConfirmModalShown(false)}
+        onClickDeleteButton={resetAllSettings}
       />
       />
 
 
       <div className="selecting-bot-type mb-5">
       <div className="selecting-bot-type mb-5">

+ 120 - 95
src/server/routes/apiv3/slack-integration-settings.js

@@ -2,6 +2,7 @@ const mongoose = require('mongoose');
 const express = require('express');
 const express = require('express');
 const { body } = require('express-validator');
 const { body } = require('express-validator');
 const axios = require('axios');
 const axios = require('axios');
+const urljoin = require('url-join');
 const loggerFactory = require('@alias/logger');
 const loggerFactory = require('@alias/logger');
 
 
 const { getConnectionStatuses } = require('@growi/slack');
 const { getConnectionStatuses } = require('@growi/slack');
@@ -15,7 +16,7 @@ const router = express.Router();
 /**
 /**
  * @swagger
  * @swagger
  *  tags:
  *  tags:
- *    name: SlackIntegration
+ *    name: SlackIntegrationSettings
  */
  */
 
 
 /**
 /**
@@ -23,14 +24,9 @@ const router = express.Router();
  *
  *
  *  components:
  *  components:
  *    schemas:
  *    schemas:
- *      CustomBotWithoutProxy:
- *        description: CustomBotWithoutProxy
- *        type: object
+ *      BotType:
+ *        description: BotType
  *        properties:
  *        properties:
- *          slackSigningSecret:
- *            type: string
- *          slackBotToken:
- *            type: string
  *          currentBotType:
  *          currentBotType:
  *            type: string
  *            type: string
  *      SlackIntegration:
  *      SlackIntegration:
@@ -49,6 +45,8 @@ module.exports = (crowi) => {
   const csrf = require('../../middlewares/csrf')(crowi);
   const csrf = require('../../middlewares/csrf')(crowi);
   const apiV3FormValidator = require('../../middlewares/apiv3-form-validator')(crowi);
   const apiV3FormValidator = require('../../middlewares/apiv3-form-validator')(crowi);
 
 
+  const SlackAppIntegration = mongoose.model('SlackAppIntegration');
+
   const validator = {
   const validator = {
     BotType: [
     BotType: [
       body('currentBotType').isString(),
       body('currentBotType').isString(),
@@ -82,9 +80,9 @@ module.exports = (crowi) => {
 
 
   async function getConnectionStatusesFromProxy(tokens) {
   async function getConnectionStatusesFromProxy(tokens) {
     const csv = tokens.join(',');
     const csv = tokens.join(',');
+    const proxyUri = crowi.configManager.getConfig('crowi', 'slackbot:serverUri');
 
 
-    // TODO: retrieve proxy url from configManager
-    const result = await axios.get('http://localhost:8080/g2s/connection-status', {
+    const result = await axios.get(urljoin(proxyUri, '/g2s/connection-status'), {
       headers: {
       headers: {
         'x-growi-gtop-tokens': csv,
         'x-growi-gtop-tokens': csv,
       },
       },
@@ -96,7 +94,7 @@ module.exports = (crowi) => {
   /**
   /**
    * @swagger
    * @swagger
    *
    *
-   *    /slack-integration/:
+   *    /slack-integration-settings/:
    *      get:
    *      get:
    *        tags: [SlackBotSettingParams]
    *        tags: [SlackBotSettingParams]
    *        operationId: getSlackBotSettingParams
    *        operationId: getSlackBotSettingParams
@@ -107,6 +105,7 @@ module.exports = (crowi) => {
    *            description: Succeeded to get info.
    *            description: Succeeded to get info.
    */
    */
   router.get('/', accessTokenParser, loginRequiredStrictly, adminRequired, async(req, res) => {
   router.get('/', accessTokenParser, loginRequiredStrictly, adminRequired, async(req, res) => {
+
     const { configManager } = crowi;
     const { configManager } = crowi;
     const currentBotType = configManager.getConfig('crowi', 'slackbot:currentBotType');
     const currentBotType = configManager.getConfig('crowi', 'slackbot:currentBotType');
 
 
@@ -119,14 +118,10 @@ module.exports = (crowi) => {
       settings.slackBotToken = configManager.getConfig('crowi', 'slackbot:token');
       settings.slackBotToken = configManager.getConfig('crowi', 'slackbot:token');
     }
     }
     else {
     else {
-      // settings.proxyUriEnvVars = ;
-      // settings.proxyUri = ;
-      // settings.tokenPtoG = ;
-      // settings.tokenGtoP = ;
+      settings.proxyUri = crowi.configManager.getConfig('crowi', 'slackbot:serverUri');
+      settings.proxyUriEnvVars = configManager.getConfigFromEnvVars('crowi', 'slackbot:serverUri');
     }
     }
 
 
-    // TODO: try-catch
-
     // retrieve connection statuses
     // retrieve connection statuses
     let connectionStatuses;
     let connectionStatuses;
     if (currentBotType == null) {
     if (currentBotType == null) {
@@ -136,13 +131,35 @@ module.exports = (crowi) => {
       const token = settings.slackBotToken;
       const token = settings.slackBotToken;
       // check the token is not null
       // check the token is not null
       if (token != null) {
       if (token != null) {
-        connectionStatuses = await getConnectionStatuses([token]);
+        try {
+          connectionStatuses = await getConnectionStatuses([token]);
+        }
+        catch (error) {
+          const msg = 'Error occured in getting connection statuses';
+          logger.error('Error', error);
+          return res.apiv3Err(new ErrorV3(msg, 'get-connection-failed'), 500);
+        }
       }
       }
     }
     }
     else {
     else {
-      // TODO: retrieve tokenGtoPs from DB
-      const tokenGtoPs = ['gtop1'];
-      connectionStatuses = (await getConnectionStatusesFromProxy(tokenGtoPs)).connectionStatuses;
+      const proxyUri = settings.proxyUri;
+
+      if (proxyUri != null) {
+        try {
+          const slackAppIntegrations = await SlackAppIntegration.find();
+          settings.slackAppIntegrations = slackAppIntegrations;
+
+          if (slackAppIntegrations.length > 0) {
+            const tokenGtoPs = slackAppIntegrations.map(slackAppIntegration => slackAppIntegration.tokenGtoP);
+            connectionStatuses = (await getConnectionStatusesFromProxy(tokenGtoPs)).connectionStatuses;
+          }
+        }
+        catch (error) {
+          const msg = 'Error occured in getting connection statuses';
+          logger.error('Error', error);
+          return res.apiv3Err(new ErrorV3(msg, 'get-connection-failed'), 500);
+        }
+      }
     }
     }
 
 
     return res.apiv3({ currentBotType, settings, connectionStatuses });
     return res.apiv3({ currentBotType, settings, connectionStatuses });
@@ -151,7 +168,7 @@ module.exports = (crowi) => {
   /**
   /**
    * @swagger
    * @swagger
    *
    *
-   *    /slack-integration/:
+   *    /slack-integration-settings/:
    *      put:
    *      put:
    *        tags: [SlackIntegration]
    *        tags: [SlackIntegration]
    *        operationId: putSlackIntegration
    *        operationId: putSlackIntegration
@@ -167,101 +184,112 @@ module.exports = (crowi) => {
    *           200:
    *           200:
    *             description: Succeeded to put Slack Integration setting.
    *             description: Succeeded to put Slack Integration setting.
    */
    */
-  router.put('/',
-    accessTokenParser, loginRequiredStrictly, adminRequired, csrf, validator.SlackIntegration, apiV3FormValidator, async(req, res) => {
-      const { currentBotType } = req.body;
+  router.put('/', accessTokenParser, loginRequiredStrictly, adminRequired, csrf, validator.SlackIntegration, apiV3FormValidator, async(req, res) => {
+    const { currentBotType } = req.body;
 
 
-      const requestParams = {
-        'slackbot:currentBotType': currentBotType,
-      };
+    const requestParams = {
+      'slackbot:currentBotType': currentBotType,
+    };
 
 
-      try {
-        await updateSlackBotSettings(requestParams);
-        crowi.slackBotService.publishUpdatedMessage();
+    try {
+      await updateSlackBotSettings(requestParams);
+      crowi.slackBotService.publishUpdatedMessage();
 
 
-        const slackIntegrationSettingsParams = {
-          currentBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType'),
-        };
-        return res.apiv3({ slackIntegrationSettingsParams });
-      }
-      catch (error) {
-        const msg = 'Error occured in updating Slack bot setting';
-        logger.error('Error', error);
-        return res.apiv3Err(new ErrorV3(msg, 'update-SlackIntegrationSetting-failed'), 500);
-      }
-    });
+      const slackIntegrationSettingsParams = {
+        currentBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType'),
+      };
+      return res.apiv3({ slackIntegrationSettingsParams });
+    }
+    catch (error) {
+      const msg = 'Error occured in updating Slack bot setting';
+      logger.error('Error', error);
+      return res.apiv3Err(new ErrorV3(msg, 'update-SlackIntegrationSetting-failed'), 500);
+    }
+  });
 
 
 
 
   /**
   /**
    * @swagger
    * @swagger
    *
    *
-   *    /slack-integration/custom-bot-without-proxy/:
+   *    /slack-integration-settings/bot-type/:
    *      put:
    *      put:
-   *        tags: [CustomBotWithoutProxy]
-   *        operationId: putCustomBotWithoutProxy
-   *        summary: /slack-integration/custom-bot-without-proxy
-   *        description: Put customBotWithoutProxy setting.
+   *        tags: [botType]
+   *        operationId: putBotType
+   *        summary: /slack-integration/bot-type
+   *        description: Put botType setting.
    *        requestBody:
    *        requestBody:
    *          required: true
    *          required: true
    *          content:
    *          content:
    *            application/json:
    *            application/json:
    *              schema:
    *              schema:
-   *                $ref: '#/components/schemas/CustomBotWithoutProxy'
+   *                $ref: '#/components/schemas/BotType'
    *        responses:
    *        responses:
    *           200:
    *           200:
-   *             description: Succeeded to put CustomBotWithoutProxy setting.
+   *             description: Succeeded to put botType setting.
    */
    */
-  router.put('/bot-type',
-    accessTokenParser, loginRequiredStrictly, adminRequired, csrf, validator.BotType, apiV3FormValidator, async(req, res) => {
-      const { currentBotType } = req.body;
-
-      await resetAllBotSettings();
-      const requestParams = { 'slackbot:currentBotType': currentBotType };
+  router.put('/bot-type', accessTokenParser, loginRequiredStrictly, adminRequired, csrf, validator.BotType, apiV3FormValidator, async(req, res) => {
+    const { currentBotType } = req.body;
 
 
-      try {
-        await updateSlackBotSettings(requestParams);
-        crowi.slackBotService.publishUpdatedMessage();
+    await resetAllBotSettings();
+    const requestParams = { 'slackbot:currentBotType': currentBotType };
 
 
-        // TODO Impl to delete AccessToken both of Proxy and GROWI when botType changes.
-        const slackBotTypeParam = { slackBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType') };
-        return res.apiv3({ slackBotTypeParam });
-      }
-      catch (error) {
-        const msg = 'Error occured in updating Custom bot setting';
-        logger.error('Error', error);
-        return res.apiv3Err(new ErrorV3(msg, 'update-CustomBotSetting-failed'), 500);
-      }
-    });
+    try {
+      await updateSlackBotSettings(requestParams);
+      crowi.slackBotService.publishUpdatedMessage();
 
 
-  /*
-    TODO: add swagger by GW-5930
-  */
+      // TODO Impl to delete AccessToken both of Proxy and GROWI when botType changes.
+      const slackBotTypeParam = { slackBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType') };
+      return res.apiv3({ slackBotTypeParam });
+    }
+    catch (error) {
+      const msg = 'Error occured in updating Custom bot setting';
+      logger.error('Error', error);
+      return res.apiv3Err(new ErrorV3(msg, 'update-CustomBotSetting-failed'), 500);
+    }
+  });
 
 
-  router.delete('/bot-type',
-    accessTokenParser, loginRequiredStrictly, adminRequired, csrf, apiV3FormValidator, async(req, res) => {
+  /**
+   * @swagger
+   *
+   *    /slack-integration/bot-type/:
+   *      delete:
+   *        tags: [botType]
+   *        operationId: deleteBotType
+   *        summary: /slack-integration/bot-type
+   *        description: Delete botType setting.
+   *        requestBody:
+   *          content:
+   *            application/json:
+   *              schema:
+   *                $ref: '#/components/schemas/BotType'
+   *        responses:
+   *           200:
+   *             description: Succeeded to delete botType setting.
+   */
+  router.delete('/bot-type', accessTokenParser, loginRequiredStrictly, adminRequired, csrf, apiV3FormValidator, async(req, res) => {
 
 
-      await resetAllBotSettings();
-      const params = { 'slackbot:currentBotType': null };
+    await resetAllBotSettings();
+    const params = { 'slackbot:currentBotType': null };
 
 
-      try {
-        await updateSlackBotSettings(params);
-        crowi.slackBotService.publishUpdatedMessage();
+    try {
+      await updateSlackBotSettings(params);
+      crowi.slackBotService.publishUpdatedMessage();
 
 
-        // TODO Impl to delete AccessToken both of Proxy and GROWI when botType changes.
-        const slackBotTypeParam = { slackBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType') };
-        return res.apiv3({ slackBotTypeParam });
-      }
-      catch (error) {
-        const msg = 'Error occured in updating Custom bot setting';
-        logger.error('Error', error);
-        return res.apiv3Err(new ErrorV3(msg, 'update-CustomBotSetting-failed'), 500);
-      }
-    });
+      // TODO Impl to delete AccessToken both of Proxy and GROWI when botType changes.
+      const slackBotTypeParam = { slackBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType') };
+      return res.apiv3({ slackBotTypeParam });
+    }
+    catch (error) {
+      const msg = 'Error occured in updating Custom bot setting';
+      logger.error('Error', error);
+      return res.apiv3Err(new ErrorV3(msg, 'update-CustomBotSetting-failed'), 500);
+    }
+  });
 
 
   /**
   /**
    * @swagger
    * @swagger
    *
    *
-   *    /slack-integration/without-proxy/update-settings/:
+   *    /slack-integration-settings/without-proxy/update-settings/:
    *      put:
    *      put:
    *        tags: [UpdateWithoutProxySettings]
    *        tags: [UpdateWithoutProxySettings]
    *        operationId: putWithoutProxySettings
    *        operationId: putWithoutProxySettings
@@ -271,12 +299,13 @@ module.exports = (crowi) => {
    *           200:
    *           200:
    *             description: Succeeded to put CustomBotWithoutProxy setting.
    *             description: Succeeded to put CustomBotWithoutProxy setting.
    */
    */
-  router.put('/without-proxy/update-settings', async(req, res) => {
+  router.put('/without-proxy/update-settings', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
     const currentBotType = crowi.configManager.getConfig('crowi', 'slackbot:currentBotType');
     const currentBotType = crowi.configManager.getConfig('crowi', 'slackbot:currentBotType');
     if (currentBotType !== 'customBotWithoutProxy') {
     if (currentBotType !== 'customBotWithoutProxy') {
       const msg = 'Not CustomBotWithoutProxy';
       const msg = 'Not CustomBotWithoutProxy';
       return res.apiv3Err(new ErrorV3(msg, 'not-customBotWithoutProxy'), 400);
       return res.apiv3Err(new ErrorV3(msg, 'not-customBotWithoutProxy'), 400);
     }
     }
+
     const { slackSigningSecret, slackBotToken } = req.body;
     const { slackSigningSecret, slackBotToken } = req.body;
     const requestParams = {
     const requestParams = {
       'slackbot:signingSecret': slackSigningSecret,
       'slackbot:signingSecret': slackSigningSecret,
@@ -297,15 +326,13 @@ module.exports = (crowi) => {
       logger.error('Error', error);
       logger.error('Error', error);
       return res.apiv3Err(new ErrorV3(msg, 'update-CustomBotSetting-failed'), 500);
       return res.apiv3Err(new ErrorV3(msg, 'update-CustomBotSetting-failed'), 500);
     }
     }
-
-
   });
   });
 
 
 
 
   /**
   /**
    * @swagger
    * @swagger
    *
    *
-   *    /slack-integration/access-tokens:
+   *    /slack-integration-settings/access-tokens:
    *      put:
    *      put:
    *        tags: [SlackIntegration]
    *        tags: [SlackIntegration]
    *        operationId: putAccessTokens
    *        operationId: putAccessTokens
@@ -316,7 +343,6 @@ module.exports = (crowi) => {
    *            description: Succeeded to update access tokens for slack
    *            description: Succeeded to update access tokens for slack
    */
    */
   router.put('/access-tokens', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
   router.put('/access-tokens', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
-    const SlackAppIntegration = mongoose.model('SlackAppIntegration');
     let checkTokens;
     let checkTokens;
     let tokenGtoP;
     let tokenGtoP;
     let tokenPtoG;
     let tokenPtoG;
@@ -367,7 +393,6 @@ module.exports = (crowi) => {
 
 
   router.put('/proxy-uri', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
   router.put('/proxy-uri', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
     const { proxyUri } = req.body;
     const { proxyUri } = req.body;
-    console.log('proxyUri', proxyUri);
 
 
     const requestParams = { 'slackbot:serverUri': proxyUri };
     const requestParams = { 'slackbot:serverUri': proxyUri };