Taichi Masuyama 4 лет назад
Родитель
Сommit
3a252a28fc

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

@@ -215,7 +215,7 @@ export class SlackCtrl {
 
     // forward to GROWI server
     if (relationsForBroadcastUse.length > 0) {
-      this.sendCommand(growiCommand, relationsForBroadcastUse, body);
+      return this.sendCommand(growiCommand, relationsForBroadcastUse, body);
     }
 
     // when all of GROWI disallowed

+ 12 - 1
packages/slackbot-proxy/src/services/RelationsService.ts

@@ -26,7 +26,18 @@ export class RelationsService {
   }
 
   async syncSupportedGrowiCommands(relation:Relation): Promise<Relation> {
-    const res = await this.getSupportedGrowiCommands(relation);
+    // assure forward compatibility GROWI version <= 4.3.0
+    let res;
+    try {
+      res = await this.getSupportedGrowiCommands(relation);
+    }
+    catch (err) {
+      if (err.response && err.response.status === 403) {
+        // this code runs if GROWI version <= 4.3.0
+        return relation;
+      }
+      throw err;
+    }
     const { supportedCommandsForBroadcastUse, supportedCommandsForSingleUse } = res.data;
     relation.supportedCommandsForBroadcastUse = supportedCommandsForBroadcastUse;
     relation.supportedCommandsForSingleUse = supportedCommandsForSingleUse;