41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?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,
|
||
]);
|
||
}
|
||
}
|