zahmis před 4 roky
rodič
revize
4b8706d838

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

@@ -65,7 +65,6 @@ module.exports = (crowi) => {
       payload = JSON.parse(req.body.payload);
       payload = JSON.parse(req.body.payload);
     }
     }
 
 
-    console.log(req.body);
 
 
     if (req.body.text == null && !payload) { // when /relation-test
     if (req.body.text == null && !payload) { // when /relation-test
       return next();
       return next();
@@ -92,6 +91,10 @@ module.exports = (crowi) => {
       next();
       next();
     }
     }
 
 
+    if (search.includes(req.body.channel_name)) {
+      next();
+    }
+
     // validate
     // validate
     if (command && !supportedCommands.includes(command)) {
     if (command && !supportedCommands.includes(command)) {
       return res.status(403).send(`It is not allowed to run '${command}' command to this GROWI.`);
       return res.status(403).send(`It is not allowed to run '${command}' command to this GROWI.`);
@@ -99,7 +102,6 @@ module.exports = (crowi) => {
     if ((actionId || callbackId) && !isActionSupported) {
     if ((actionId || callbackId) && !isActionSupported) {
       return res.status(403).send(`It is not allowed to run '${command}' command to this GROWI.`);
       return res.status(403).send(`It is not allowed to run '${command}' command to this GROWI.`);
     }
     }
-
     next();
     next();
   }
   }
 
 

+ 9 - 3
packages/slackbot-proxy/src/controllers/slack.ts

@@ -216,10 +216,8 @@ export class SlackCtrl {
       const permittedCreateCommandArray = permittedChannelsForEachCommand?.create;
       const permittedCreateCommandArray = permittedChannelsForEachCommand?.create;
       const permittedSearchCommandArray = permittedChannelsForEachCommand?.search;
       const permittedSearchCommandArray = permittedChannelsForEachCommand?.search;
 
 
-
       const isCreate = permittedCreateCommandArray?.includes(body.channel_name);
       const isCreate = permittedCreateCommandArray?.includes(body.channel_name);
       if (isCreate) {
       if (isCreate) {
-        console.log('isCreate 内部');
         const relationsForBroadcastUse:RelationMock[] = [];
         const relationsForBroadcastUse:RelationMock[] = [];
         body.permittedChannelsForEachCommand = relations[0].permittedChannelsForEachCommand;
         body.permittedChannelsForEachCommand = relations[0].permittedChannelsForEachCommand;
         relationsForBroadcastUse.push(relations[0]);
         relationsForBroadcastUse.push(relations[0]);
@@ -227,7 +225,15 @@ export class SlackCtrl {
         return this.sendCommand(growiCommand, relationsForBroadcastUse, body);
         return this.sendCommand(growiCommand, relationsForBroadcastUse, body);
       }
       }
 
 
-      console.log('230');
+      const isSearch = permittedSearchCommandArray?.includes(body.channel_name);
+      if (isSearch) {
+        console.log('isSearch');
+        const relationsForBroadcastUse:RelationMock[] = [];
+        body.permittedChannelsForEachCommand = relations[0].permittedChannelsForEachCommand;
+        relationsForBroadcastUse.push(relations[0]);
+        console.log(relations[0].permittedChannelsForEachCommand);
+        return this.sendCommand(growiCommand, relationsForBroadcastUse, body);
+      }
       return client.chat.postEphemeral({
       return client.chat.postEphemeral({
         text: 'Error occured.',
         text: 'Error occured.',
         channel: body.channel_id,
         channel: body.channel_id,