kaori hace 5 años
padre
commit
d2acdebee5
Se han modificado 1 ficheros con 16 adiciones y 14 borrados
  1. 16 14
      packages/slackbot-proxy/src/controllers/slack.ts

+ 16 - 14
packages/slackbot-proxy/src/controllers/slack.ts

@@ -81,7 +81,7 @@ export class SlackCtrl {
   @UseBefore(AuthorizeCommandMiddleware)
   @UseBefore(AuthorizeCommandMiddleware)
   async handleCommand(@Req() req: AuthedReq, @Res() res: Res): Promise<void|string> {
   async handleCommand(@Req() req: AuthedReq, @Res() res: Res): Promise<void|string> {
     const { body, authorizeResult } = req;
     const { body, authorizeResult } = req;
-
+    console.log('authorizeResult(commands)', authorizeResult);
     if (body.text == null) {
     if (body.text == null) {
       return 'No text.';
       return 'No text.';
     }
     }
@@ -98,6 +98,7 @@ export class SlackCtrl {
       return;
       return;
     }
     }
 
 
+
     /*
     /*
      * forward to GROWI server
      * forward to GROWI server
      */
      */
@@ -129,12 +130,22 @@ export class SlackCtrl {
     // return;
     // return;
 
 
     const { body, authorizeResult } = req;
     const { body, authorizeResult } = req;
+    const installationId = authorizeResult.enterpriseId || authorizeResult.teamId;
+    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+    const installation = await this.installationRepository.findByTeamIdOrEnterpriseId(installationId!);
+    const relations = await this.relationRepository.find({ installation: installation?.id });
     console.log('authorizeResult', authorizeResult);
     console.log('authorizeResult', authorizeResult);
 
 
-    const installation = await this.installationRepository.findByID('1');
-    if (installation == null) {
-      throw new Error('installation is reqiured');
-    }
+    // Find the latest order by installationId and GROWIurl
+    await this.orderRepository.findOne({
+      installation: installation?.id,
+      // growiUrl
+    }, {
+      order: {
+        createdAt: 'DESC',
+      },
+    });
+
 
 
     const handleViewSubmission = async(inputValues) => {
     const handleViewSubmission = async(inputValues) => {
 
 
@@ -180,15 +191,6 @@ export class SlackCtrl {
 
 
     }
     }
 
 
-
-    //   // Find the latest order by installationId and GROWIurl
-    const order = await this.orderRepository.findOne({
-      installation: installation.id,
-    }, {
-      order: {
-        createdAt: 'DESC',
-      },
-    });
   }
   }
 
 
   @Post('/events')
   @Post('/events')