Explorar el Código

create class at registerService

zahmis hace 5 años
padre
commit
fda95e93a0

+ 3 - 1
packages/slackbot-proxy/.env.development

@@ -3,4 +3,6 @@ TYPEORM_HOST=mysql
 TYPEORM_DATABASE=growi-slackbot-proxy
 TYPEORM_USERNAME=growi-slackbot-proxy
 TYPEORM_PASSWORD=YrkUi7rCW46Z2N6EXSFUBwaQTUR8biCU
-
+SLACK_CLIENT_ID=1399660543842.1865744087568
+SLACK_CLIENT_SECRET=6220f652fe6e13523167831e701ddcfa
+SLACK_BOT_USER_OAUTH_TOKEN=xoxb-1399660543842-1848670292404-5ThQnq44EyJfRiGNCdrhsqKb

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

@@ -1,12 +1,13 @@
 import {
   BodyParams, Controller, Get, Inject, Post, Req, Res,
 } from '@tsed/common';
-import { supportedGrowiCommandsMappings, supportedGrowiCommandsAction } from '@growi/slack/src/index';
+import { supportedGrowiCommandsMappings } from '@growi/slack/src/index';
 import { Installation } from '~/entities/installation';
 import { InstallationRepository } from '~/repositories/installation';
 
 import { InstallerService } from '~/services/InstallerService';
 import { ReceiveService } from '~/services/RecieveService';
+import { RegisterService } from '~/services/RegisterService';
 
 @Controller('/slack')
 export class SlackCtrl {
@@ -21,6 +22,8 @@ export class SlackCtrl {
   @Inject()
   receiveService: ReceiveService;
 
+  registerService: RegisterService;
+
   @Get('/testsave')
   testsave(): void {
     const installation = new Installation();
@@ -65,6 +68,11 @@ export class SlackCtrl {
 
     console.log(body.text);
     const method = supportedGrowiCommandsMappings[body.text];
+    const modulePath = `../service/${method}`;
+    const hoge = require(modulePath);
+    console.log('hoge', hoge);
+
+    console.log(modulePath);
     console.log(method);
 
     const slackInput = this.receiveService.receiveContentsFromSlack(body);

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

@@ -1,6 +1,6 @@
 import { Service } from '@tsed/di';
 import { parse } from '@growi/slack/src/utils/slash-command-parser';
-import { openRegisterModal } from './RegisterService';
+// import { openRegisterModal } from './RegisterService';
 
 @Service()
 export class ReceiveService {
@@ -9,7 +9,7 @@ export class ReceiveService {
     const parseBody = parse(body);
 
     if (parseBody.growiCommandType === 'register') {
-      await openRegisterModal(body);
+      // await openRegisterModal(body);
       return 'register action occurd';
     }
 

+ 45 - 29
packages/slackbot-proxy/src/services/RegisterService.ts

@@ -1,32 +1,48 @@
 import { WebClient, LogLevel } from '@slack/web-api';
 import { generateInputSectionBlock } from '@growi/slack/src/utils/block-creater';
 
-export const openRegisterModal = async(body:{[key:string]:string}) : Promise<void> => {
-
-  // tmp use process.env
-  const client = new WebClient(process.env.SLACK_BOT_USER_OAUTH_TOKEN, { logLevel: LogLevel.DEBUG });
-  await client.views.open({
-    trigger_id: body.trigger_id,
-    view: {
-      type: 'modal',
-      title: {
-        type: 'plain_text',
-        text: 'Register Credentials',
-      },
-      submit: {
-        type: 'plain_text',
-        text: 'Submit',
-      },
-      close: {
-        type: 'plain_text',
-        text: 'Close',
-      },
-      blocks: [
-        generateInputSectionBlock('growiDomain', 'GROWI domain', 'contents_input', false, 'https://example.com'),
-        generateInputSectionBlock('growiAccessToken', 'GROWI ACCESS_TOKEN', 'contents_input', false, 'jBMZvpk.....'),
-        generateInputSectionBlock('proxyToken', 'PROXY ACCESS_TOKEM', 'contents_input', false, 'jBMZvpk.....'),
-
-      ],
-    },
-  });
-};
+
+import { Service } from '@tsed/di';
+import { parse } from '@growi/slack/src/utils/slash-command-parser';
+
+@Service()
+
+export class RegisterService {
+
+  hoge() {
+    return 'hoge';
+  }
+
+
+}
+
+
+// export const openRegisterModal = async(body:{[key:string]:string}) : Promise<void> => {
+
+//   // tmp use process.env
+//   const client = new WebClient(process.env.SLACK_BOT_USER_OAUTH_TOKEN, { logLevel: LogLevel.DEBUG });
+//   await client.views.open({
+//     trigger_id: body.trigger_id,
+//     view: {
+//       type: 'modal',
+//       title: {
+//         type: 'plain_text',
+//         text: 'Register Credentials',
+//       },
+//       submit: {
+//         type: 'plain_text',
+//         text: 'Submit',
+//       },
+//       close: {
+//         type: 'plain_text',
+//         text: 'Close',
+//       },
+//       blocks: [
+//         generateInputSectionBlock('growiDomain', 'GROWI domain', 'contents_input', false, 'https://example.com'),
+//         generateInputSectionBlock('growiAccessToken', 'GROWI ACCESS_TOKEN', 'contents_input', false, 'jBMZvpk.....'),
+//         generateInputSectionBlock('proxyToken', 'PROXY ACCESS_TOKEM', 'contents_input', false, 'jBMZvpk.....'),
+
+//       ],
+//     },
+//   });
+// };