itizawa 4 лет назад
Родитель
Сommit
0ae443b26d
1 измененных файлов с 13 добавлено и 1 удалено
  1. 13 1
      src/server/routes/apiv3/slack-integration-settings.js

+ 13 - 1
src/server/routes/apiv3/slack-integration-settings.js

@@ -513,8 +513,9 @@ module.exports = (crowi) => {
 
 
     const { slackAppIntegrationId } = req.body;
     const { slackAppIntegrationId } = req.body;
     let slackBotToken;
     let slackBotToken;
+    let slackAppIntegration;
     try {
     try {
-      const slackAppIntegration = await SlackAppIntegration.findOne({ _id: slackAppIntegrationId });
+      slackAppIntegration = await SlackAppIntegration.findOne({ _id: slackAppIntegrationId });
       if (slackAppIntegration == null) {
       if (slackAppIntegration == null) {
         const msg = 'Could not find SlackAppIntegration by id';
         const msg = 'Could not find SlackAppIntegration by id';
         return res.apiv3Err(new ErrorV3(msg, 'find-slackAppIntegration-failed'), 400);
         return res.apiv3Err(new ErrorV3(msg, 'find-slackAppIntegration-failed'), 400);
@@ -531,6 +532,17 @@ module.exports = (crowi) => {
       return res.apiv3Err(new ErrorV3(`Error occured while testing. Cause: ${error.message}`, 'test-failed', error.stack));
       return res.apiv3Err(new ErrorV3(`Error occured while testing. Cause: ${error.message}`, 'test-failed', error.stack));
     }
     }
 
 
+    try {
+      slackAppIntegration = await SlackAppIntegration.findByIdAndUpdate(slackAppIntegrationId, { slackBotToken });
+    }
+    catch (error) {
+      logger.error('Error', error);
+      return res.apiv3Err(new ErrorV3(
+        `Error occured while updationg slackAppIntegration. Cause: ${error.message}`,
+        'update-slackAppIntegration-failed', error.stack,
+      ));
+    }
+
     const { channel } = req.body;
     const { channel } = req.body;
     const appSiteURL = crowi.configManager.getConfig('crowi', 'app:siteUrl');
     const appSiteURL = crowi.configManager.getConfig('crowi', 'app:siteUrl');
     try {
     try {