Yuki Takei 10 месяцев назад
Родитель
Сommit
f2bd00dc0d
1 измененных файлов с 7 добавлено и 9 удалено
  1. 7 9
      apps/app/src/server/routes/apiv3/slack-integration.js

+ 7 - 9
apps/app/src/server/routes/apiv3/slack-integration.js

@@ -5,25 +5,25 @@ import { InvalidGrowiCommandError } from '@growi/slack/dist/models';
 import { markdownSectionBlock } from '@growi/slack/dist/utils/block-kit-builder';
 import { InteractionPayloadAccessor } from '@growi/slack/dist/utils/interaction-payload-accessor';
 import { generateRespondUtil } from '@growi/slack/dist/utils/respond-util-factory';
+import { isValidResponseUrl } from '@growi/slack/dist/utils/response-url-validator';
 import { parseSlashCommand } from '@growi/slack/dist/utils/slash-command-parser';
+import express from 'express';
+import { body } from 'express-validator';
 import createError from 'http-errors';
+import mongoose from 'mongoose';
 
 import { SlackCommandHandlerError } from '~/server/models/vo/slack-command-handler-error';
 import { configManager } from '~/server/service/config-manager';
 import { growiInfoService } from '~/server/service/growi-info';
 import loggerFactory from '~/utils/logger';
 
-
-const express = require('express');
-const { body } = require('express-validator');
-const mongoose = require('mongoose');
+import { handleError } from '../../service/slack-command-handler/error-handler';
+import { checkPermission } from '../../util/slack-integration';
 
 
 const logger = loggerFactory('growi:routes:apiv3:slack-integration');
 const router = express.Router();
 const SlackAppIntegration = mongoose.model('SlackAppIntegration');
-const { handleError } = require('../../service/slack-command-handler/error-handler');
-const { checkPermission } = require('../../util/slack-integration');
 
 /** @param {import('~/server/crowi').default} crowi Crowi instance */
 module.exports = (crowi) => {
@@ -295,15 +295,13 @@ module.exports = (crowi) => {
   // TODO: this method will be a middleware when typescriptize in the future
   function getResponseUrl(req) {
     const { body } = req;
-    const { crowi } = req;
     const responseUrl = body?.growiCommand?.responseUrl ?? body.response_url;
 
     if (responseUrl == null) {
       return null;
     }
 
-    const proxyUri = crowi.slackIntegrationService.proxyUriForCurrentType;
-    const { isValidResponseUrl } = require('@growi/slack/src/utils/response-url-validator');
+    const proxyUri = slackIntegrationService.proxyUriForCurrentType;
 
     if (!isValidResponseUrl(responseUrl, proxyUri)) {
       throw createError(400, 'Invalid response_url');