Просмотр исходного кода

Merge branch 'feat/create-endpoint-growi-register' into feat/create-modal-after-typing-growi-register

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

+ 1 - 3
packages/slack/src/utils/slash-command-parser.ts

@@ -1,9 +1,7 @@
-import { SlashCommand } from '@slack/bolt';
-
 import { GrowiCommand } from '../interfaces/growi-command';
 import { InvalidGrowiCommandError } from '../models/errors';
 
-export const parse = (slashCommand: SlashCommand): GrowiCommand => {
+export const parse = (slashCommand:{[key:string]:string}): GrowiCommand => {
   const splitted = slashCommand.text.split(' ');
   if (splitted.length < 1) {
     throw new InvalidGrowiCommandError('The SlashCommand.text does not specify GrowiCommand type');

+ 0 - 0
packages/slackbot-proxy/data/sqlite.db


+ 2 - 1
packages/slackbot-proxy/package.json

@@ -28,7 +28,8 @@
     "compression": "^1.7.4",
     "dotenv-flow": "^3.2.0",
     "mysql2": "^2.2.5",
-    "typeorm": "^0.2.31"
+    "typeorm": "^0.2.31",
+    "@growi/slack":"0.9.0-RC"
   },
   "devDependencies": {
     "@tsed/core": "^6.34.3",

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

@@ -1,4 +1,3 @@
-import { SlashCommand } from '@slack/bolt';
 import {
   BodyParams, Controller, Get, Inject, Post, Req, Res,
 } from '@tsed/common';
@@ -59,7 +58,7 @@ export class SlackCtrl {
   }
 
   @Post('/events')
-  handleEvent(@BodyParams() body:SlashCommand, @Res() res: Res): string {
+  handleEvent(@BodyParams() body:{[key:string]:string}, @Res() res: Res): string {
     // Send response immediately to avoid opelation_timeout error
     // See https://api.slack.com/apis/connections/events-api#the-events-api__responding-to-events
 

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

@@ -1,12 +1,11 @@
 import { Service } from '@tsed/di';
-import { SlashCommand } from '@slack/bolt';
+import { parse } from '@growi/slack/src/utils/slash-command-parser';
 import { openRegisterModal } from './RegisterService';
-import { parse } from '../../../slack/src/utils/slash-command-parser';
 
 @Service()
 export class ReceiveService {
 
-  async receiveContentsFromSlack(body:SlashCommand) : Promise<string> {
+  receiveContentsFromSlack(body:{[key:string]:string}) : string {
     const parseBody = parse(body);
 
     if (parseBody.growiCommandType === 'register') {

+ 3 - 4
packages/slackbot-proxy/src/services/RegisterService.ts

@@ -1,8 +1,7 @@
-import { SlashCommand } from '@slack/bolt';
 import { WebClient, LogLevel } from '@slack/web-api';
-import { generateInputSectionBlock, generateMarkdownSectionBlock } from '../../../slack/src/utils/block-creater';
+import { generateInputSectionBlock, generateMarkdownSectionBlock } from '@growi/slack/src/utils/block-creater';
 
-export const openRegisterModal = async(body:SlashCommand) : Promise<void> => {
+export const openRegisterModal = async(body:{[key:string]:string}) : Promise<void> => {
 
   const client = new WebClient('xoxb-1399660543842-1848670292404-TYsbWjgHPtNcTvqupgwb3h75', { logLevel: LogLevel.DEBUG });
   await client.views.open({
@@ -19,7 +18,7 @@ export const openRegisterModal = async(body:SlashCommand) : Promise<void> => {
       },
       blocks: [
         generateMarkdownSectionBlock('hoge'),
-        // generateInputSectionBlock('contents', 'Contents', 'contents_input', true, 'Input with Markdown...'),
+        generateInputSectionBlock('contents', 'Contents', 'contents_input', true, 'Input with Markdown...'),
 
       ],
     },