Browse Source

feat: disable webhook if tg is not enabled

M1Screw 2 years ago
parent
commit
fc341b0f19
6 changed files with 3 additions and 44 deletions
  1. 0 21
      app/container.php
  2. 0 19
      app/envload.php
  3. 0 1
      console
  4. 0 1
      public/index.php
  5. 3 1
      src/Controllers/HomeController.php
  6. 0 1
      xcat

+ 0 - 21
app/container.php

@@ -1,21 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-use Slim\Container;
-
-/**
- * Container Builder
- *
- * @return Container
- */
-
-$configuration = [
-    'settings' => [
-        'debug' => $_ENV['debug'],
-        'whoops.editor' => 'sublime',
-        'displayErrorDetails' => $_ENV['debug'],
-    ],
-];
-
-return new Container($configuration);

+ 0 - 19
app/envload.php

@@ -1,19 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-if (getenv('UIM_ENV_REPLACE_ENABLE')) {
-    foreach (getenv() as $envKey => $envValue) {
-        global $_ENV;
-        $envUpKey = strtoupper($envKey);
-        // Key starts with UIM_
-        if (str_starts_with($envUpKey, 'UIM_')) {
-            // Valid env key, set to _ENV
-            $configKey = substr($envUpKey, 4);
-            $realKey = App\Utils\Tools::searchEnvName($configKey);
-            if ($realKey !== null) {
-                $_ENV[$realKey] = $envValue;
-            }
-        }
-    }
-}

+ 0 - 1
console

@@ -9,7 +9,6 @@ use Symfony\Component\Console\Application;
 require __DIR__ . '/app/predefine.php';
 require __DIR__ . '/vendor/autoload.php';
 require __DIR__ . '/config/.config.php';
-require __DIR__ . '/app/envload.php';
 
 Boot::setTime();
 Boot::bootSentry();

+ 0 - 1
public/index.php

@@ -13,7 +13,6 @@ require_once __DIR__ . '/../vendor/autoload.php';
 require_once __DIR__ . '/../config/.config.php';
 require_once __DIR__ . '/../config/appprofile.php';
 require_once __DIR__ . '/../app/predefine.php';
-require_once __DIR__ . '/../app/envload.php';
 
 use App\Middleware\ErrorHandler;
 use App\Services\Boot;

+ 3 - 1
src/Controllers/HomeController.php

@@ -52,12 +52,14 @@ final class HomeController extends BaseController
     public function telegram(ServerRequest $request, Response $response, array $args): ResponseInterface
     {
         $token = $request->getQueryParam('token');
-        if ($token === $_ENV['telegram_request_token']) {
+
+        if ($_ENV['enable_telegram'] && $token === $_ENV['telegram_request_token']) {
             Process::index();
             $result = '1';
         } else {
             $result = '0';
         }
+
         return $response->write($result);
     }
 }

+ 0 - 1
xcat

@@ -8,7 +8,6 @@ use App\Services\Boot;
 require __DIR__ . '/app/predefine.php';
 require __DIR__ . '/vendor/autoload.php';
 require __DIR__ . '/config/.config.php';
-require __DIR__ . '/app/envload.php';
 
 Boot::setTime();
 Boot::bootSentry();