|
|
@@ -1,6 +1,7 @@
|
|
|
import {
|
|
|
Controller, Get, Inject, Req, Res, UseBefore,
|
|
|
} from '@tsed/common';
|
|
|
+import axios from 'axios';
|
|
|
|
|
|
import { WebAPICallResult } from '@slack/web-api';
|
|
|
|
|
|
@@ -98,6 +99,19 @@ export class GrowiToSlackCtrl {
|
|
|
return res.status(400).send({ message: 'order has expired or does not exist.' });
|
|
|
}
|
|
|
|
|
|
+ // Access the GROWI URL saved in the Order record and check if the GtoP token is valid.
|
|
|
+ try {
|
|
|
+ const url = new URL('/_api/v3/slack-integration/proxied/commands', order.growiUrl);
|
|
|
+ await axios.post(url.toString(), {
|
|
|
+ type: 'url_verification',
|
|
|
+ tokenPtoG: order.growiAccessToken,
|
|
|
+ challenge: 'this_is_my_challenge_token',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ logger.error(err);
|
|
|
+ }
|
|
|
+
|
|
|
logger.debug('order found', order);
|
|
|
|
|
|
const token = order.installation.data.bot?.token;
|