Taichi Masuyama vor 4 Jahren
Ursprung
Commit
a0a235e1cc
1 geänderte Dateien mit 10 neuen und 1 gelöschten Zeilen
  1. 10 1
      packages/slackbot-proxy/src/controllers/slack.ts

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

@@ -170,7 +170,7 @@ export class SlackCtrl {
 
 
     // Send response immediately to avoid opelation_timeout error
     // Send response immediately to avoid opelation_timeout error
     // See https://api.slack.com/apis/connections/events-api#the-events-api__responding-to-events
     // See https://api.slack.com/apis/connections/events-api#the-events-api__responding-to-events
-    // For commands other than register, unregister, and status
+    // This is for select_growi. This is necessary because select_growi process might update cache
     // res.send()
     // res.send()
     res.send({
     res.send({
       response_type: 'ephemeral',
       response_type: 'ephemeral',
@@ -274,6 +274,7 @@ export class SlackCtrl {
 
 
     // register
     // register
     if (callBackId === 'register') {
     if (callBackId === 'register') {
+      // TODO: CHECK
       try {
       try {
         await this.registerService.insertOrderRecord(installation, authorizeResult.botToken, payload);
         await this.registerService.insertOrderRecord(installation, authorizeResult.botToken, payload);
       }
       }
@@ -291,12 +292,14 @@ export class SlackCtrl {
 
 
     // unregister
     // unregister
     if (callBackId === 'unregister') {
     if (callBackId === 'unregister') {
+      // TODO: CHECK
       await this.unregisterService.unregister(installation, authorizeResult, payload);
       await this.unregisterService.unregister(installation, authorizeResult, payload);
       return;
       return;
     }
     }
 
 
     // forward to GROWI server
     // forward to GROWI server
     if (callBackId === 'select_growi') {
     if (callBackId === 'select_growi') {
+      // TODO: CHECK
       const selectedGrowiInformation = await this.selectGrowiService.handleSelectInteraction(installation, payload);
       const selectedGrowiInformation = await this.selectGrowiService.handleSelectInteraction(installation, payload);
       return this.sendCommand(selectedGrowiInformation.growiCommand, [selectedGrowiInformation.relation], selectedGrowiInformation.sendCommandBody);
       return this.sendCommand(selectedGrowiInformation.growiCommand, [selectedGrowiInformation.relation], selectedGrowiInformation.sendCommandBody);
     }
     }
@@ -313,6 +316,12 @@ export class SlackCtrl {
 
 
     try {
     try {
       // generate API URL
       // generate API URL
+      // Send response immediately to avoid opelation_timeout error
+      // See https://api.slack.com/apis/connections/events-api#the-events-api__responding-to-events
+      res.send({
+        response_type: 'ephemeral',
+        text: 'Processing your request ...',
+      });
       const url = new URL('/_api/v3/slack-integration/proxied/interactions', req.growiUri);
       const url = new URL('/_api/v3/slack-integration/proxied/interactions', req.growiUri);
       await axios.post(url.toString(), {
       await axios.post(url.toString(), {
         ...body,
         ...body,