소스 검색

use generateWebClient

itizawa 4 년 전
부모
커밋
fbfa2be5c9
1개의 변경된 파일7개의 추가작업 그리고 5개의 파일을 삭제
  1. 7 5
      packages/slackbot-proxy/src/services/SelectRequestService.ts

+ 7 - 5
packages/slackbot-proxy/src/services/SelectRequestService.ts

@@ -1,8 +1,7 @@
 import { Service } from '@tsed/di';
 import axios from 'axios';
 
-import { WebClient, LogLevel } from '@slack/web-api';
-import { GrowiCommand } from '@growi/slack';
+import { GrowiCommand, generateWebClient } from '@growi/slack';
 import { AuthorizeResult } from '@slack/oauth';
 
 import { GrowiCommandProcessor } from '~/interfaces/slack-to-growi/growi-command-processor';
@@ -10,15 +9,18 @@ import { RelationRepository } from '~/repositories/relation';
 import { Installation } from '~/entities/installation';
 
 
-const isProduction = process.env.NODE_ENV === 'production';
-
 @Service()
 export class SelectRequestService implements GrowiCommandProcessor {
 
   async process(growiCommand: GrowiCommand, authorizeResult: AuthorizeResult, body: {[key:string]:string } & {growiUris:string[]}): Promise<void> {
     const { botToken } = authorizeResult;
 
-    const client = new WebClient(botToken, { logLevel: isProduction ? LogLevel.DEBUG : LogLevel.INFO });
+    if (botToken == null) {
+      throw new Error('botToken is required.');
+    }
+
+    const client = generateWebClient(botToken);
+
     await client.views.open({
       trigger_id: body.trigger_id,
       view: {