Ver código fonte

add proxy url at server

zahmis 4 anos atrás
pai
commit
7cc13a71e4

+ 0 - 1
config/env.dev.js

@@ -28,5 +28,4 @@ module.exports = {
   SALT_FOR_PTOG_TOKEN: 'growi',
   // GROWI_CLOUD_URI: 'http://growi.cloud',
   // GROWI_APP_ID_FOR_GROWI_CLOUD: '012345',
-  OFFICIAL_BOT_PROXY_URL: 'https://slackbot-proxy.growi.org',
 };

+ 4 - 4
src/client/js/components/Admin/SlackIntegration/OfficialBotSettings.jsx

@@ -13,7 +13,7 @@ const logger = loggerFactory('growi:SlackBotSettings');
 
 const OfficialBotSettings = (props) => {
   const {
-    appContainer, slackAppIntegrations, proxyServerUri, onClickAddSlackWorkspaceBtn, connectionStatuses, onUpdateTokens, onSubmitForm,
+    appContainer, slackAppIntegrations, /* proxyServerUri, */ onClickAddSlackWorkspaceBtn, connectionStatuses, onUpdateTokens, onSubmitForm,
   } = props;
   const [siteName, setSiteName] = useState('');
   const [integrationIdToDelete, setIntegrationIdToDelete] = useState(null);
@@ -58,7 +58,7 @@ const OfficialBotSettings = (props) => {
             connectionStatuses={connectionStatuses}
           />
 
-          <div className="form-group row my-4">
+          {/* <div className="form-group row my-4">
             <label className="text-left text-md-right col-md-3 col-form-label mt-3">Proxy URL</label>
             <div className="col-md-6 mt-3">
               <input
@@ -69,7 +69,7 @@ const OfficialBotSettings = (props) => {
                 readOnly
               />
             </div>
-          </div>
+          </div> */}
 
           <h2 className="admin-setting-header">{t('admin:slack_integration.integration_procedure')}</h2>
         </>
@@ -136,7 +136,7 @@ OfficialBotSettings.propTypes = {
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
 
   slackAppIntegrations: PropTypes.array,
-  proxyServerUri: PropTypes.string,
+  // proxyServerUri: PropTypes.string,
   onClickAddSlackWorkspaceBtn: PropTypes.func,
   onDeleteSlackAppIntegration: PropTypes.func,
   connectionStatuses: PropTypes.object.isRequired,

+ 24 - 25
src/client/js/components/Admin/SlackIntegration/SlackIntegration.jsx

@@ -13,10 +13,9 @@ import BotTypeCard from './BotTypeCard';
 import DeleteSlackBotSettingsModal from './DeleteSlackBotSettingsModal';
 
 const botTypes = ['officialBot', 'customBotWithoutProxy', 'customBotWithProxy'];
-const officialBotProxyUri = process.env.OFFICIAL_BOT_PROXY_URL;
-
 
 const SlackIntegration = (props) => {
+
   const { appContainer } = props;
   const { t } = useTranslation();
   const [currentBotType, setCurrentBotType] = useState(null);
@@ -93,17 +92,17 @@ const SlackIntegration = (props) => {
         currentBotType: botType,
       });
       setSelectedBotType(null);
-      if (botType === 'officialBot') {
-        try {
-          await appContainer.apiv3.put('/slack-integration-settings/proxy-uri', {
-            proxyUri: officialBotProxyUri,
-          });
-          toastSuccess(t('toaster.update_successed', { target: t('Proxy URL') }));
-        }
-        catch (err) {
-          toastError(err);
-        }
-      }
+      // if (botType === 'officialBot') {
+      //   try {
+      //     await appContainer.apiv3.put('/slack-integration-settings/proxy-uri', {
+      //       proxyUri: officialBotProxyUri,
+      //     });
+      //     toastSuccess(t('toaster.update_successed', { target: t('Proxy URL') }));
+      //   }
+      //   catch (err) {
+      //     toastError(err);
+      //   }
+      // }
       fetchSlackIntegrationData();
     }
     catch (err) {
@@ -118,17 +117,17 @@ const SlackIntegration = (props) => {
     if (currentBotType == null) {
       return changeCurrentBotSettings(botType);
     }
-    if (botType === 'officialBot') {
-      try {
-        await appContainer.apiv3.put('/slack-integration-settings/proxy-uri', {
-          proxyUri: officialBotProxyUri,
-        });
-        toastSuccess(t('toaster.update_successed', { target: t('Proxy URL') }));
-      }
-      catch (err) {
-        toastError(err);
-      }
-    }
+    // if (botType === 'officialBot') {
+    //   try {
+    //     await appContainer.apiv3.put('/slack-integration-settings/proxy-uri', {
+    //       proxyUri: officialBotProxyUri,
+    //     });
+    //     toastSuccess(t('toaster.update_successed', { target: t('Proxy URL') }));
+    //   }
+    //   catch (err) {
+    //     toastError(err);
+    //   }
+    // }
     setSelectedBotType(botType);
   };
 
@@ -148,7 +147,7 @@ const SlackIntegration = (props) => {
       settingsComponent = (
         <OfficialBotSettings
           slackAppIntegrations={slackAppIntegrations}
-          proxyServerUri={officialBotProxyUri}
+          // proxyServerUri={officialBotProxyUri}
           onClickAddSlackWorkspaceBtn={createSlackIntegrationData}
           onDeleteSlackAppIntegration={fetchSlackIntegrationData}
           connectionStatuses={connectionStatuses}

+ 4 - 0
src/server/routes/apiv3/slack-integration-settings.js

@@ -273,6 +273,10 @@ module.exports = (crowi) => {
     await resetAllBotSettings();
     const requestParams = { 'slackbot:currentBotType': currentBotType };
 
+    if (currentBotType === 'officialBot') {
+      requestParams['slackbot:proxyServerUri'] = 'https://slackbot-proxy.growi.org';
+    }
+
     try {
       await updateSlackBotSettings(requestParams);
       crowi.slackBotService.publishUpdatedMessage();