import { Service } from '@tsed/di'; import { WebClient, LogLevel } from '@slack/web-api'; import { generateInputSectionBlock, GrowiCommand } from '@growi/slack'; import { AuthorizeResult } from '@slack/oauth'; import { GrowiCommandProcessor } from '~/interfaces/growi-command-processor'; @Service() export class RegisterService implements GrowiCommandProcessor { async process(growiCommand: GrowiCommand, authorizeResult: AuthorizeResult, body: {[key:string]:string}): Promise { const { botToken } = authorizeResult; // tmp use process.env const client = new WebClient(botToken, { 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.....'), ], }, }); } }