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

temp commentout proxy to growi

zahmis 4 лет назад
Родитель
Сommit
d9c99931a4
1 измененных файлов с 33 добавлено и 33 удалено
  1. 33 33
      packages/app/src/server/routes/apiv3/slack-integration.js

+ 33 - 33
packages/app/src/server/routes/apiv3/slack-integration.js

@@ -57,13 +57,13 @@ module.exports = (crowi) => {
 
     // const relation = await SlackAppIntegration.findOne({ tokenPtoG });
     // MOCK DATA DELETE THIS GW-6972 ---------------
-    const SlackAppIntegrationMock = mongoose.model('SlackAppIntegrationMock');
-    const relation = await SlackAppIntegrationMock.findOne({ tokenPtoG });
-    const channelsObject = relation.permittedChannelsForEachCommand._doc.channelsObject;
-    // MOCK DATA DELETE THIS GW-6972 ---------------
-    const { supportedCommandsForBroadcastUse, supportedCommandsForSingleUse } = relation;
-    const supportedCommands = supportedCommandsForBroadcastUse.concat(supportedCommandsForSingleUse);
-    const supportedGrowiActionsRegExps = getSupportedGrowiActionsRegExps(supportedCommands);
+    // const SlackAppIntegrationMock = mongoose.model('SlackAppIntegrationMock');
+    // const relation = await SlackAppIntegrationMock.findOne({ tokenPtoG });
+    // const channelsObject = relation.permittedChannelsForEachCommand._doc.channelsObject;
+    // // MOCK DATA DELETE THIS GW-6972 ---------------
+    // const { supportedCommandsForBroadcastUse, supportedCommandsForSingleUse } = relation;
+    // const supportedCommands = supportedCommandsForBroadcastUse.concat(supportedCommandsForSingleUse);
+    // const supportedGrowiActionsRegExps = getSupportedGrowiActionsRegExps(supportedCommands);
 
     // get command name from req.body
     let command = '';
@@ -81,34 +81,34 @@ module.exports = (crowi) => {
     }
 
     // code below checks permission at channel level
-    const fromChannel = req.body.channel_name; /* || payload.channel.name; */
-    [...channelsObject.keys()].forEach((commandName) => {
-      const permittedChannels = channelsObject.get(commandName);
-      // ex. search OR search:hogehoge
-      const commandRegExp = new RegExp(`(^${commandName}$)|(^${commandName}:\\w+)`);
-
-      // RegExp check
-      if (commandRegExp.test(commandName) || commandRegExp.test(actionId) || commandRegExp.test(callbackId)) {
-        // check if the channel is permitted
-        if (permittedChannels.includes(fromChannel)) return next();
-      }
-    });
+    // const fromChannel = req.body.channel_name; /* || payload.channel.name; */
+    // [...channelsObject.keys()].forEach((commandName) => {
+    //   const permittedChannels = channelsObject.get(commandName);
+    //   // ex. search OR search:hogehoge
+    //   const commandRegExp = new RegExp(`(^${commandName}$)|(^${commandName}:\\w+)`);
+
+    //   // RegExp check
+    //   if (commandRegExp.test(commandName) || commandRegExp.test(actionId) || commandRegExp.test(callbackId)) {
+    //     // check if the channel is permitted
+    //     if (permittedChannels.includes(fromChannel)) return next();
+    //   }
+    // });
 
     // code below checks permission at command level
-    let isActionSupported = false;
-    supportedGrowiActionsRegExps.forEach((regexp) => {
-      if (regexp.test(actionId) || regexp.test(callbackId)) {
-        isActionSupported = true;
-      }
-    });
-
-    // validate
-    if (command && !supportedCommands.includes(command)) {
-      return res.status(403).send(`It is not allowed to run '${command}' command to this GROWI.`);
-    }
-    if ((actionId || callbackId) && !isActionSupported) {
-      return res.status(403).send(`It is not allowed to run '${command}' command to this GROWI.`);
-    }
+    // let isActionSupported = false;
+    // supportedGrowiActionsRegExps.forEach((regexp) => {
+    //   if (regexp.test(actionId) || regexp.test(callbackId)) {
+    //     isActionSupported = true;
+    //   }
+    // });
+
+    // // validate
+    // if (command && !supportedCommands.includes(command)) {
+    //   return res.status(403).send(`It is not allowed to run '${command}' command to this GROWI.`);
+    // }
+    // if ((actionId || callbackId) && !isActionSupported) {
+    //   return res.status(403).send(`It is not allowed to run '${command}' command to this GROWI.`);
+    // }
 
     next();
   }