Răsfoiți Sursa

add the endpoint to show "Add to Slack" button

Yuki Takei 5 ani în urmă
părinte
comite
22abc6c2a7
1 a modificat fișierele cu 21 adăugiri și 1 ștergeri
  1. 21 1
      packages/slackbot-proxy/src/controllers/slack.ts

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

@@ -28,6 +28,26 @@ export class SlackCtrl {
     });
   }
 
+  @Get('/install')
+  async install(): Promise<string> {
+    const url = await this.installer.generateInstallUrl({
+      // Add the scopes your app needs
+      scopes: [
+        'channels:history',
+        'commands',
+        'groups:history',
+        'im:history',
+        'mpim:history',
+        'chat:write',
+      ],
+    });
+
+    return `<a href="${url}">`
+      // eslint-disable-next-line max-len
+      + '<img alt="Add to Slack" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcSet="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/add_to_slack@2x.png 2x" />'
+      + '</a>';
+  }
+
   @Post('/events')
   handlewEvent(@BodyParams() body: any, @Res() res: Res): string {
     // Send response immediately to avoid opelation_timeout error
@@ -43,7 +63,7 @@ export class SlackCtrl {
   handleOauthRedirect(@Req() req: Req, @Res() res: Res): void {
     // illegal state
     // TODO: https://youtrack.weseek.co.jp/issue/GW-5543
-    if (req.query.state !== 'init') {
+    if (req.query.state === '') {
       throw new Error('illegal state');
     }