|
|
@@ -14,7 +14,6 @@ export class RegisterService implements GrowiCommandProcessor {
|
|
|
async process(growiCommand: GrowiCommand, authorizeResult: AuthorizeResult, body: {[key:string]:string}): Promise<void> {
|
|
|
const { botToken } = authorizeResult;
|
|
|
|
|
|
- // tmp use process.env
|
|
|
const client = new WebClient(botToken, { logLevel: isProduction ? LogLevel.DEBUG : LogLevel.INFO });
|
|
|
await client.views.open({
|
|
|
trigger_id: body.trigger_id,
|
|
|
@@ -32,26 +31,12 @@ export class RegisterService implements GrowiCommandProcessor {
|
|
|
type: 'plain_text',
|
|
|
text: 'Close',
|
|
|
},
|
|
|
+ private_metadata: JSON.stringify({ channel: body.channel_name }),
|
|
|
+
|
|
|
blocks: [
|
|
|
generateInputSectionBlock('growiDomain', 'GROWI domain', 'contents_input', false, 'https://example.com'),
|
|
|
generateInputSectionBlock('growiAccessToken', 'GROWI ACCESS_TOKEN', 'contents_input', false, 'jBMZvpk.....'),
|
|
|
generateInputSectionBlock('proxyToken', 'PROXY ACCESS_TOKEN', 'contents_input', false, 'jBMZvpk.....'),
|
|
|
- // added an input block to make response_url enabled and get info (block_id, action_id, channel_id, response_url)
|
|
|
- // refer to https://api.slack.com/surfaces/modals/using#modal_response_url
|
|
|
- {
|
|
|
- block_id: 'channel_to_post_proxy_url',
|
|
|
- type: 'input',
|
|
|
- label: {
|
|
|
- type: 'plain_text',
|
|
|
- text: 'Select a channel to post the proxy URL on',
|
|
|
- },
|
|
|
- element: {
|
|
|
- action_id: 'submit_growi_url_and_access_tokens',
|
|
|
- type: 'conversations_select',
|
|
|
- response_url_enabled: true,
|
|
|
- default_to_current_conversation: true,
|
|
|
- },
|
|
|
- },
|
|
|
],
|
|
|
},
|
|
|
});
|
|
|
@@ -77,13 +62,14 @@ export class RegisterService implements GrowiCommandProcessor {
|
|
|
): Promise<void> {
|
|
|
|
|
|
const { botToken } = authorizeResult;
|
|
|
+ const { channel } = JSON.parse(payload.view.private_metadata);
|
|
|
|
|
|
const serverUri = process.env.SERVER_URI;
|
|
|
|
|
|
const client = new WebClient(botToken, { logLevel: isProduction ? LogLevel.DEBUG : LogLevel.INFO });
|
|
|
|
|
|
await client.chat.postEphemeral({
|
|
|
- channel: payload.response_urls[0].channel_id,
|
|
|
+ channel,
|
|
|
user: payload.user.id,
|
|
|
// Recommended including 'text' to provide a fallback when using blocks
|
|
|
// refer to https://api.slack.com/methods/chat.postEphemeral#text_usage
|