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

Merge branch 'feat/growi-bot' into feat/5559-access-token-to-db

Steven Fukase 5 лет назад
Родитель
Сommit
6ae0d862a6

+ 2 - 2
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettings.jsx

@@ -14,7 +14,7 @@ const CustomBotWithoutProxySettings = (props) => {
   const [slackBotToken, setSlackBotToken] = useState('');
   const [slackSigningSecretEnv, setSlackSigningSecretEnv] = useState('');
   const [slackBotTokenEnv, setSlackBotTokenEnv] = useState('');
-  const botType = 'custom-bot-without-proxy';
+  const currentBotType = 'custom-bot-without-proxy';
   const fetchData = useCallback(async() => {
     try {
       const res = await appContainer.apiv3.get('/slack-integration/');
@@ -40,7 +40,7 @@ const CustomBotWithoutProxySettings = (props) => {
       await appContainer.apiv3.put('/slack-integration/custom-bot-without-proxy', {
         slackSigningSecret,
         slackBotToken,
-        botType,
+        currentBotType,
       });
       toastSuccess(t('toaster.update_successed', { target: t('admin:slack_integration.custom_bot_without_proxy_settings') }));
     }

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

@@ -53,7 +53,7 @@ const SlackIntegration = (props) => {
       const res = await appContainer.apiv3.put('slack-integration/custom-bot-without-proxy', {
         slackSigningSecret: '',
         slackBotToken: '',
-        botType: selectedBotType,
+        currentBotType: selectedBotType,
       });
       setCurrentBotType(res.data.customBotWithoutProxySettingParams.slackBotType);
       setSelectedBotType(null);

+ 15 - 10
src/server/routes/apiv3/slack-integration.js

@@ -27,7 +27,7 @@ const router = express.Router();
  *            type: string
  *          slackBotToken:
  *            type: string
- *          botType:
+ *          currentBotType:
  *            type: string
  *      SlackIntegration:
  *        description: SlackIntegration
@@ -49,7 +49,7 @@ module.exports = (crowi) => {
     CustomBotWithoutProxy: [
       body('slackSigningSecret').isString(),
       body('slackBotToken').isString(),
-      body('botType').isString(),
+      body('currentBotType').isString(),
     ],
     SlackIntegration: [
       body('currentBotType')
@@ -78,7 +78,7 @@ module.exports = (crowi) => {
    *      get:
    *        tags: [SlackBotSettingParams]
    *        operationId: getSlackBotSettingParams
-   *        summary: /slack-integration
+   *        summary: get /slack-integration
    *        description: Get slackBot setting params.
    *        responses:
    *          200:
@@ -88,7 +88,7 @@ module.exports = (crowi) => {
 
     const slackBotSettingParams = {
       accessToken: crowi.configManager.getConfig('crowi', 'slackbot:accessToken'),
-      currentBotType: crowi.configManager.getConfig('crowi', 'slackbot:type'),
+      currentBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType'),
       // TODO impl when creating official bot
       officialBotSettings: {
         // TODO impl this after GW-4939
@@ -118,7 +118,7 @@ module.exports = (crowi) => {
    *      put:
    *        tags: [SlackIntegration]
    *        operationId: putSlackIntegration
-   *        summary: /slack-integration/slack-integration
+   *        summary: put /slack-integration
    *        description: Put SlackIntegration setting.
    *        requestBody:
    *          required: true
@@ -135,13 +135,18 @@ module.exports = (crowi) => {
       const { currentBotType } = req.body;
 
       const requestParams = {
-        'slackbot:type': currentBotType,
+        'slackbot:currentBotType': currentBotType,
       };
 
       try {
         await updateSlackBotSettings(requestParams);
+
+        // initialize bolt service
+        crowi.boltService.initialize();
+        crowi.boltService.publishUpdatedMessage();
+
         const slackIntegrationSettingsParams = {
-          currentBotType: crowi.configManager.getConfig('crowi', 'slackbot:type'),
+          currentBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType'),
         };
         return res.apiv3({ slackIntegrationSettingsParams });
       }
@@ -173,12 +178,12 @@ module.exports = (crowi) => {
    */
   router.put('/custom-bot-without-proxy',
     accessTokenParser, loginRequiredStrictly, adminRequired, csrf, validator.CustomBotWithoutProxy, apiV3FormValidator, async(req, res) => {
-      const { slackSigningSecret, slackBotToken, botType } = req.body;
+      const { slackSigningSecret, slackBotToken, currentBotType } = req.body;
 
       const requestParams = {
         'slackbot:signingSecret': slackSigningSecret,
         'slackbot:token': slackBotToken,
-        'slackbot:type': botType,
+        'slackbot:currentBotType': currentBotType,
       };
 
       try {
@@ -192,7 +197,7 @@ module.exports = (crowi) => {
         const customBotWithoutProxySettingParams = {
           slackSigningSecret: crowi.configManager.getConfig('crowi', 'slackbot:signingSecret'),
           slackBotToken: crowi.configManager.getConfig('crowi', 'slackbot:token'),
-          slackBotType: crowi.configManager.getConfig('crowi', 'slackbot:type'),
+          slackBotType: crowi.configManager.getConfig('crowi', 'slackbot:currentBotType'),
         };
         return res.apiv3({ customBotWithoutProxySettingParams });
       }