|
|
@@ -88,6 +88,18 @@ export class RegisterService implements GrowiCommandProcessor {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ async replyToSlack(client: WebClient, channel: string, user: string, text: string, blocks: any): Promise<void> {
|
|
|
+ await client.chat.postEphemeral({
|
|
|
+ channel,
|
|
|
+ user,
|
|
|
+ // Recommended including 'text' to provide a fallback when using blocks
|
|
|
+ // refer to https://api.slack.com/methods/chat.postEphemeral#text_usage
|
|
|
+ text,
|
|
|
+ blocks,
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
async notifyServerUriToSlack(
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
|
botToken: string | undefined, payload: any,
|
|
|
@@ -100,31 +112,42 @@ export class RegisterService implements GrowiCommandProcessor {
|
|
|
const client = new WebClient(botToken, { logLevel: isProduction ? LogLevel.DEBUG : LogLevel.INFO });
|
|
|
|
|
|
if (isOfficialMode) {
|
|
|
- await client.chat.postEphemeral({
|
|
|
- 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
|
|
|
- text: 'Proxy URL',
|
|
|
- blocks: [
|
|
|
- generateMarkdownSectionBlock('Successfully registered with the proxy! Please check test connection in your GROWI'),
|
|
|
- ],
|
|
|
- });
|
|
|
+ const blocks = [
|
|
|
+ generateMarkdownSectionBlock('Successfully registered with the proxy! Please check test connection in your GROWI'),
|
|
|
+ ];
|
|
|
+ await this.replyToSlack(client, channel, payload.user.id, 'Proxy URL', blocks);
|
|
|
+ // await client.chat.postEphemeral({
|
|
|
+ // 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
|
|
|
+ // text: 'Proxy URL',
|
|
|
+ // blocks: [
|
|
|
+ // generateMarkdownSectionBlock('Successfully registered with the proxy! Please check test connection in your GROWI'),
|
|
|
+ // ],
|
|
|
+ // });
|
|
|
return;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- await client.chat.postEphemeral({
|
|
|
- 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
|
|
|
- text: 'Proxy URL',
|
|
|
- blocks: [
|
|
|
- generateMarkdownSectionBlock('Please enter and update the following Proxy URL to slack bot setting form in your GROWI'),
|
|
|
- generateMarkdownSectionBlock(`Proxy URL: ${serverUri}`),
|
|
|
- ],
|
|
|
- });
|
|
|
- return;
|
|
|
+ const blocks = [
|
|
|
+ generateMarkdownSectionBlock('Please enter and update the following Proxy URL to slack bot setting form in your GROWI'),
|
|
|
+ generateMarkdownSectionBlock(`Proxy URL: ${serverUri}`),
|
|
|
+ ];
|
|
|
+ await this.replyToSlack(client, channel, payload.user.id, 'Proxy URL', blocks);
|
|
|
+
|
|
|
+ // await client.chat.postEphemeral({
|
|
|
+ // 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
|
|
|
+ // text: 'Proxy URL',
|
|
|
+ // blocks: [
|
|
|
+ // generateMarkdownSectionBlock('Please enter and update the following Proxy URL to slack bot setting form in your GROWI'),
|
|
|
+ // generateMarkdownSectionBlock(`Proxy URL: ${serverUri}`),
|
|
|
+ // ],
|
|
|
+ // });
|
|
|
+ // return;
|
|
|
}
|
|
|
|
|
|
}
|