zahmis 4 лет назад
Родитель
Сommit
0ee9b81b98
1 измененных файлов с 18 добавлено и 17 удалено
  1. 18 17
      packages/slackbot-proxy/src/controllers/slack.ts

+ 18 - 17
packages/slackbot-proxy/src/controllers/slack.ts

@@ -212,25 +212,26 @@ export class SlackCtrl {
         const fromChannel = body.channel_name;
 
         // permitted channel
-        if (permittedChannels.includes(fromChannel)) {
-          const relationsForSingleUse:RelationMock[] = [];
-          body.permittedChannelsForEachCommand = relations[0].permittedChannelsForEachCommand;
-          relationsForSingleUse.push(relations[0]);
-          return this.sendCommand(growiCommand, relationsForSingleUse, body);
+        const isPermittedChannel = permittedChannels.includes(fromChannel);
+        if (!isPermittedChannel) {
+          const botToken = relations[0].installation?.data.bot?.token;
+
+          // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+          const client = generateWebClient(botToken!);
+          return client.chat.postEphemeral({
+            text: 'Error occured.',
+            channel: body.channel_id,
+            user: body.user_id,
+            blocks: [
+              markdownSectionBlock(`It is not allowed to run *'${growiCommand.growiCommandType}'* command to this GROWI.`),
+            ],
+          });
         }
 
-        const botToken = relations[0].installation?.data.bot?.token;
-
-        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-        const client = generateWebClient(botToken!);
-        return client.chat.postEphemeral({
-          text: 'Error occured.',
-          channel: body.channel_id,
-          user: body.user_id,
-          blocks: [
-            markdownSectionBlock(`It is not allowed to run *'${growiCommand.growiCommandType}'* command to this GROWI.`),
-          ],
-        });
+        const relationsForSingleUse:RelationMock[] = [];
+        body.permittedChannelsForEachCommand = relations[0].permittedChannelsForEachCommand;
+        relationsForSingleUse.push(relations[0]);
+        return this.sendCommand(growiCommand, relationsForSingleUse, body);
       });
     }
   }