zahmis 5 лет назад
Родитель
Сommit
f768cc209b
2 измененных файлов с 16 добавлено и 6 удалено
  1. 11 6
      packages/slack/src/index.ts
  2. 5 0
      packages/slackbot-proxy/src/controllers/slack.ts

+ 11 - 6
packages/slack/src/index.ts

@@ -1,12 +1,17 @@
-// import { RegisterService } from '../../slackbot-proxy/src/services/RegisterService';
+import { openRegisterModal } from '../../slackbot-proxy/src/services/RegisterService';
 
 
 export const supportedSlackCommands: string[] = [
   '/growi',
 ];
 
-export const supportedGrowiCommands: string[] = [
-  'search',
-  'create',
-  'register',
-];
+export const supportedGrowiCommandsMappings = {
+  search: 'search',
+  create: 'create',
+  register: 'register',
+};
+
+
+export const supportedGrowiCommandsAction = {
+  register: (body:{[key:string]:string}) => openRegisterModal(body),
+};

+ 5 - 0
packages/slackbot-proxy/src/controllers/slack.ts

@@ -1,6 +1,7 @@
 import {
   BodyParams, Controller, Get, Inject, Post, Req, Res,
 } from '@tsed/common';
+import { supportedGrowiCommandsMappings, supportedGrowiCommandsAction } from '@growi/slack/src/index';
 import { Installation } from '~/entities/installation';
 import { InstallationRepository } from '~/repositories/installation';
 
@@ -62,6 +63,10 @@ export class SlackCtrl {
     // Send response immediately to avoid opelation_timeout error
     // See https://api.slack.com/apis/connections/events-api#the-events-api__responding-to-events
 
+    console.log(body.text);
+    const method = supportedGrowiCommandsMappings[body.text];
+    console.log(method);
+
     const slackInput = this.receiveService.receiveContentsFromSlack(body);
     console.log('Controller/events', slackInput);
     res.send();