|
|
@@ -3,7 +3,10 @@ import {
|
|
|
} from '@tsed/common';
|
|
|
|
|
|
import { Installation } from '~/entities/installation';
|
|
|
+import { Order } from '~/entities/order';
|
|
|
+
|
|
|
import { InstallationRepository } from '~/repositories/installation';
|
|
|
+import { OrderRepository } from '~/repositories/order';
|
|
|
import { InstallerService } from '~/services/InstallerService';
|
|
|
|
|
|
|
|
|
@@ -16,6 +19,9 @@ export class SlackCtrl {
|
|
|
@Inject()
|
|
|
installationRepository: InstallationRepository;
|
|
|
|
|
|
+ @Inject()
|
|
|
+ orderRepository: OrderRepository;
|
|
|
+
|
|
|
@Get('/testsave')
|
|
|
testsave(): void {
|
|
|
const installation = new Installation();
|
|
|
@@ -56,13 +62,16 @@ export class SlackCtrl {
|
|
|
}
|
|
|
|
|
|
@Post('/events')
|
|
|
- handleEvent(@BodyParams() body: any, @Res() res: Res): string {
|
|
|
+ async handleEvent(@BodyParams() body: any, @Res() res: Res): Promise<string> {
|
|
|
// 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();
|
|
|
|
|
|
console.log('body', body);
|
|
|
|
|
|
+ const order = new Order(body.team_id);
|
|
|
+ await this.orderRepository.save(order);
|
|
|
+
|
|
|
return 'This action will be handled by bolt service.';
|
|
|
}
|
|
|
|