diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 7f5bc0f8..dcc33d94 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -101,8 +101,7 @@ class Test extends Command */ public function handle() { - $tool = new TrackerRepository(); - $result = $tool->checkStatus(); + $result = \Nexus\Plugin\Plugin::listEnabled(); dd($result); } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 6c32ab7e..1d61ed62 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -4,6 +4,8 @@ namespace App\Console; use App\Jobs\CheckCleanup; use App\Jobs\CheckQueueFailedJobs; +use App\Jobs\MaintainPluginState; +use App\Jobs\ManagePlugin; use App\Utils\ThirdPartyJob; use Carbon\Carbon; use Illuminate\Console\Scheduling\Event; @@ -43,6 +45,7 @@ class Kernel extends ConsoleKernel $schedule->command('torrent:load_pieces_hash')->dailyAt("01:00")->withoutOverlapping(); $schedule->job(new CheckQueueFailedJobs())->everySixHours()->withoutOverlapping(); $schedule->job(new ThirdPartyJob())->everyMinute()->withoutOverlapping(); + $schedule->job(new MaintainPluginState())->everyMinute()->withoutOverlapping(); $this->registerScheduleCleanup($schedule); } diff --git a/app/Filament/Resources/System/TorrentStateResource.php b/app/Filament/Resources/System/TorrentStateResource.php index 51bd13ec..629dc290 100644 --- a/app/Filament/Resources/System/TorrentStateResource.php +++ b/app/Filament/Resources/System/TorrentStateResource.php @@ -66,6 +66,8 @@ class TorrentStateResource extends Resource Tables\Actions\EditAction::make()->after(function () { do_log("cache_del: global_promotion_state"); NexusDB::cache_del(Setting::TORRENT_GLOBAL_STATE_CACHE_KEY); + do_log("publish_model_event: global_promotion_state_updated"); + publish_model_event("global_promotion_state_updated", 0); }), // Tables\Actions\DeleteAction::make(), ]) diff --git a/app/Jobs/MaintainPluginState.php b/app/Jobs/MaintainPluginState.php new file mode 100644 index 00000000..f1d84bc0 --- /dev/null +++ b/app/Jobs/MaintainPluginState.php @@ -0,0 +1,44 @@ +del($key); + $nowStr = now()->toDateTimeString(); + foreach ($enabled as $name => $value) { + NexusDB::redis()->hSet($key, $name, $nowStr); + } + do_log("$key: " . nexus_json_encode($enabled)); + } +} diff --git a/nexus/Plugin/Plugin.php b/nexus/Plugin/Plugin.php index 93633dbe..7ec962dc 100644 --- a/nexus/Plugin/Plugin.php +++ b/nexus/Plugin/Plugin.php @@ -23,6 +23,16 @@ class Plugin return !empty(self::$providers[$name]['providers']); } + public static function listEnabled(): array + { + $result = []; + //plugins are more exactly + foreach (self::$plugins as $id => $plugin) { + $result[$id] = 1; + } + return $result; + } + public static function getById($id) :BasePlugin|null { return self::$plugins[$id] ?? null;