|
|
@@ -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');
|
|
|
}
|
|
|
|