Sfoglia il codice sorgente

Merge pull request #4146 from weseek/fix/gw7109-handring-growi-command

Fix/gw7109 handring growi command
Yuki Takei 4 anni fa
parent
commit
86772e9ec9
1 ha cambiato i file con 18 aggiunte e 1 eliminazioni
  1. 18 1
      packages/slackbot-proxy/src/controllers/slack.ts

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

@@ -8,6 +8,7 @@ import { WebAPICallResult } from '@slack/web-api';
 
 import {
   markdownSectionBlock, GrowiCommand, parseSlashCommand, postEphemeralErrors, verifySlackRequest, generateWebClient,
+  InvalidGrowiCommandError,
 } from '@growi/slack';
 
 import { Relation } from '~/entities/relation';
@@ -105,7 +106,23 @@ export class SlackCtrl {
       return 'No text.';
     }
 
-    const growiCommand = parseSlashCommand(body);
+    let growiCommand;
+
+    try {
+      growiCommand = parseSlashCommand(body);
+    }
+    catch (err) {
+      if (err instanceof InvalidGrowiCommandError) {
+        res.json({
+          blocks: [
+            markdownSectionBlock('*Command type is not specified.*'),
+            markdownSectionBlock('Run `/growi help` to check the commands you can use.'),
+          ],
+        });
+      }
+      logger.error(err.message);
+      return;
+    }
 
     // register
     if (growiCommand.growiCommandType === 'register') {