diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b8406a7..ab399db 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,9 +1,9 @@ name: CI on: push: - branches: [ "main" ] + branches: [ "1.x" ] pull_request: - branches: [ "main" ] + branches: [ "1.x" ] jobs: PHPUnit: diff --git a/composer.json b/composer.json index 06ab04a..8524c06 100644 --- a/composer.json +++ b/composer.json @@ -5,9 +5,9 @@ "description": "Webman plugin workbunny/webman-push-server", "authors": [ { - "name": "chaz6chez", - "email": "chaz6chez1993@outlook.com", - "homepage": "http://chaz6chez.cn" + "name": "chaz6chez", + "email": "chaz6chez1993@outlook.com", + "homepage": "http://chaz6chez.cn" } ], "support": { @@ -15,18 +15,18 @@ "source": "https://github.com/workbunny/webman-push-server" }, "require": { - "php": ">=8.0", - "ext-json": "*", - "ext-redis": "*", - "workerman/http-client": "^1.0 | ^2.0", - "workerman/channel": "^1.0", - "webman/console": "^1.0", - "psr/container": "^1.0 | ^2.0", - "illuminate/redis": "^9.0|^10.0", - "illuminate/database": "^9.0|^10.0", - "illuminate/events": "^9.0|^10.0", - "monolog/monolog": "^2.0 | ^3.0", - "pusher/pusher-php-server": "^7.2" + "php": ">=8.0", + "ext-json": "*", + "ext-redis": "*", + "workerman/http-client": "^1.0 | ^2.0", + "workerman/channel": "^1.0", + "webman/console": "^1.0", + "psr/container": "^1.0 | ^2.0", + "illuminate/redis": "^9.0|^10.0", + "illuminate/database": "^9.0|^10.0", + "illuminate/events": "^9.0|^10.0", + "monolog/monolog": "^2.0 | ^3.0", + "pusher/pusher-php-server": "^7.2" }, "require-dev": { "workerman/webman-framework": "^1.5", diff --git a/src/HookServer.php b/src/HookServer.php index 55e0916..0655962 100644 --- a/src/HookServer.php +++ b/src/HookServer.php @@ -166,6 +166,12 @@ public function ack(string $queue, string $group, array $idArray): bool */ public function claim(string $queue, string $group, string $consumer): void { + if (!method_exists(self::getStorage(), 'xAutoClaim')) { + Log::channel('plugin.workbunny.webman-push-server.warning')->warning( + 'Method xAutoClaim requires redis-server >= 6.2.0. ' + ); + return; + } try { if ($idArray = self::getStorage()->xAutoClaim( $queue, $group, $consumer, @@ -252,13 +258,15 @@ protected function _tempInit(): void // 创建数据库结构 $builder = Db::schema('plugin.workbunny.webman-push-server.local-storage'); if (!$builder->hasTable('temp')) { - $builder->create('temp', function (Blueprint $table) { - $table->id(); - $table->string('queue'); - $table->json('data'); - $table->integer('create_at'); - }); - echo 'local-storage db created. ' . PHP_EOL; + try { + $builder->create('temp', function (Blueprint $table) { + $table->id(); + $table->string('queue'); + $table->json('data'); + $table->integer('create_at'); + }); + echo 'local-storage db created. ' . PHP_EOL; + } catch (Throwable $throwable) {} } } } @@ -311,7 +319,7 @@ function () { $interval = self::getConfig('claim_interval', 0); if ($interval > 0) { $this->_claimTimer = Timer::add( - self::getConfig('claim_interval'), + $interval, function () use ($queue, $group, $consumer) { $this->claim($queue, $group, $consumer); } diff --git a/src/WebhookHandler.php b/src/WebhookHandler.php index 8015e3b..8ca3127 100644 --- a/src/WebhookHandler.php +++ b/src/WebhookHandler.php @@ -31,6 +31,10 @@ public function run(string $queue, string $group, array $dataArray) { $idArray = array_keys($dataArray); $messageArray = array_values($dataArray); + // 如果没有配置webhook地址,直接ack + if (!HookServer::getConfig('webhook_url')) { + HookServer::instance()->ack($queue, $group, $idArray); + } // http发送 $this->_request($method = 'POST', [ 'header' => [