zahmis 5 лет назад
Родитель
Сommit
38242f1ccc

+ 8 - 3
packages/slackbot-proxy/src/controllers/slack.ts

@@ -57,15 +57,20 @@ export class SlackCtrl {
   }
 
   @Post('/events')
-  handleEvent(@BodyParams() body:{[key:string]:string}, @Res() res: Res): string {
+  async handleEvent(@BodyParams() body:{[key:string]:string}, @Res() res: Res): Promise<string> {
     // Send response immediately to avoid opelation_timeout error
     // See https://api.slack.com/apis/connections/events-api#the-events-api__responding-to-events
 
     const method = supportedGrowiCommandsMappings[body.text];
+    const methodService = `${method}Service`;
     const modulePath = `../services/${method}Service`;
     const targetModule = require(modulePath);
-    console.log('hoge', targetModule);
-    targetModule();
+    // const targetModuleAction = Object.values(targetModule);
+    const service = targetModule.methodService;
+    console.log(service);
+
+
+    // await targeModuleAction(body);
 
 
     // const slackInput = this.receiveService.receiveContentsFromSlack(body);

+ 2 - 2
packages/slackbot-proxy/src/services/RegisterService.ts

@@ -1,7 +1,7 @@
 import { WebClient, LogLevel } from '@slack/web-api';
 import { generateInputSectionBlock } from '@growi/slack/src/utils/block-creater';
 
-export const registerService = async(body:{[key:string]:string}) : Promise<void> => {
+export async function registerService(body:{[key:string]:string}): Promise<void> {
 
   // tmp use process.env
   const client = new WebClient(process.env.SLACK_BOT_USER_OAUTH_TOKEN, { logLevel: LogLevel.DEBUG });
@@ -29,4 +29,4 @@ export const registerService = async(body:{[key:string]:string}) : Promise<void>
       ],
     },
   });
-};
+}