From 667e02460cf9ff1a983a603d2d1ac20169065970 Mon Sep 17 00:00:00 2001 From: xboard Date: Thu, 6 Feb 2025 17:48:17 +0800 Subject: [PATCH] feat: add traffic.before_process hook --- .../Controllers/V2/Admin/PluginController.php | 15 +++++---------- app/Services/UserService.php | 6 ++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/V2/Admin/PluginController.php b/app/Http/Controllers/V2/Admin/PluginController.php index 4be814e..8fcc6f8 100644 --- a/app/Http/Controllers/V2/Admin/PluginController.php +++ b/app/Http/Controllers/V2/Admin/PluginController.php @@ -134,16 +134,11 @@ class PluginController extends Controller 'code' => 'required|string' ]); - try { - $this->pluginManager->disable($request->input('code')); - return response()->json([ - 'message' => '插件禁用成功' - ]); - } catch (\Exception $e) { - return response()->json([ - 'message' => '插件禁用失败:' . $e->getMessage() - ], 400); - } + $this->pluginManager->disable($request->input('code')); + return response()->json([ + 'message' => '插件禁用成功' + ]); + } /** diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 5cb45c5..a733bfc 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -8,6 +8,7 @@ use App\Jobs\TrafficFetchJob; use App\Models\Order; use App\Models\Plan; use App\Models\User; +use App\Services\Plugin\HookManager; class UserService { @@ -172,6 +173,11 @@ class UserService public function trafficFetch(array $server, string $protocol, array $data) { + list($server, $protocol, $data) = HookManager::filter('traffic.before_process', [ + $server, + $protocol, + $data + ]); $timestamp = strtotime(date('Y-m-d')); collect($data)->chunk(1000)->each(function ($chunk) use ($timestamp, $server, $protocol) {