推送模块

This commit is contained in:
2026-04-18 15:48:31 +08:00
parent e3f26ba1f7
commit 7d0f11fe43
19 changed files with 548 additions and 5 deletions

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace app\admin\controller\test;
use app\common\controller\Backend;
use app\common\library\admin\PushChannelConfigHelper;
use support\Response;
use Webman\Http\Request as WebmanRequest;
/**
* 推送测试private-user-{uuid}(用户私有频道)
*/
class PushPrivateUser extends Backend
{
protected ?object $model = null;
public function pushConfig(WebmanRequest $request): Response
{
$response = $this->initializeBackend($request);
if ($response !== null) {
return $response;
}
$uuid = trim((string) ($request->get('uuid') ?? $request->post('uuid') ?? ''));
if ($uuid === '') {
return $this->error(__('Parameter %s can not be empty', ['uuid']));
}
if (strlen($uuid) > 64 || !preg_match('/^[0-9a-zA-Z_-]+$/', $uuid)) {
return $this->error(__('Parameter error'));
}
return $this->success('', [
'url' => PushChannelConfigHelper::wsBaseUrl(),
'app_key' => PushChannelConfigHelper::appKey(),
'channel' => 'private-user-' . $uuid,
]);
}
}