|
@@ -19,6 +19,7 @@ import { AddSigningSecretToReq } from '~/middlewares/slack-to-growi/add-signing-
|
|
|
import { AuthorizeCommandMiddleware, AuthorizeInteractionMiddleware } from '~/middlewares/slack-to-growi/authorizer';
|
|
import { AuthorizeCommandMiddleware, AuthorizeInteractionMiddleware } from '~/middlewares/slack-to-growi/authorizer';
|
|
|
import { InstallerService } from '~/services/InstallerService';
|
|
import { InstallerService } from '~/services/InstallerService';
|
|
|
import { RegisterService } from '~/services/RegisterService';
|
|
import { RegisterService } from '~/services/RegisterService';
|
|
|
|
|
+import { UnregisterService } from '~/services/UnregisterService';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
|
|
|
|
@@ -43,6 +44,9 @@ export class SlackCtrl {
|
|
|
@Inject()
|
|
@Inject()
|
|
|
registerService: RegisterService;
|
|
registerService: RegisterService;
|
|
|
|
|
|
|
|
|
|
+ @Inject()
|
|
|
|
|
+ unregisterService: UnregisterService;
|
|
|
|
|
+
|
|
|
@Get('/install')
|
|
@Get('/install')
|
|
|
async install(): Promise<string> {
|
|
async install(): Promise<string> {
|
|
|
const url = await this.installerService.installer.generateInstallUrl({
|
|
const url = await this.installerService.installer.generateInstallUrl({
|
|
@@ -83,6 +87,19 @@ export class SlackCtrl {
|
|
|
return this.registerService.process(growiCommand, authorizeResult, body as {[key:string]:string});
|
|
return this.registerService.process(growiCommand, authorizeResult, body as {[key:string]:string});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // unregister
|
|
|
|
|
+ if (growiCommand.growiCommandType === 'unregister') {
|
|
|
|
|
+ if (growiCommand.growiCommandArgs.length === 0) {
|
|
|
|
|
+ return 'GROWI Urls is required.';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Send response immediately to avoid opelation_timeout error
|
|
|
|
|
+ // See https://api.slack.com/apis/connections/events-api#the-events-api__responding-to-events
|
|
|
|
|
+ res.send();
|
|
|
|
|
+
|
|
|
|
|
+ return this.unregisterService.process(growiCommand, authorizeResult, body as {[key:string]:string});
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const installationId = authorizeResult.enterpriseId || authorizeResult.teamId;
|
|
const installationId = authorizeResult.enterpriseId || authorizeResult.teamId;
|
|
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
|
const installation = await this.installationRepository.findByTeamIdOrEnterpriseId(installationId!);
|
|
const installation = await this.installationRepository.findByTeamIdOrEnterpriseId(installationId!);
|
|
@@ -173,6 +190,12 @@ export class SlackCtrl {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // unregister
|
|
|
|
|
+ if (callBackId === 'unregister') {
|
|
|
|
|
+ await this.unregisterService.unregister(this.relationRepository, installation, authorizeResult, payload);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/*
|
|
/*
|
|
|
* forward to GROWI server
|
|
* forward to GROWI server
|
|
|
*/
|
|
*/
|