You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1.3 KiB
27 lines
1.3 KiB
|
3 weeks ago
|
<?php
|
||
|
|
namespace App\Http\Controllers\Mobile;
|
||
|
|
use App\Helpers\ResponseCode;
|
||
|
|
use App\Services\ContentSecurity\AvatarCheck;
|
||
|
|
|
||
|
|
class ContentSecurityController extends CommonController
|
||
|
|
{
|
||
|
|
public function avatarStatus(AvatarCheck $checks) {
|
||
|
|
try { return $this->success($checks->result($this->getUserId(), (int) request('check_id'))); }
|
||
|
|
catch (\InvalidArgumentException $e) { return $this->fail([ResponseCode::ERROR_BUSINESS, $e->getMessage()]); }
|
||
|
|
}
|
||
|
|
public function callback(AvatarCheck $checks) {
|
||
|
|
abort_unless(config('content-security.token') && config('content-security.aes_key'), 503);
|
||
|
|
$app = miniProgramApp(['token' => config('content-security.token'), 'aes_key' => config('content-security.aes_key'), 'response_type' => 'array']);
|
||
|
|
// Explicitly bind the current request, including JSON/encrypted event bodies.
|
||
|
|
$app->rebind('request', request());
|
||
|
|
$app->server->forceValidate();
|
||
|
|
$app->server->push(function ($message) use ($checks) { $checks->receive($message); });
|
||
|
|
try {
|
||
|
|
$app->server->validate();
|
||
|
|
if (request()->isMethod('get')) return response((string) request('echostr', ''));
|
||
|
|
return $app->server->serve();
|
||
|
|
}
|
||
|
|
catch (\EasyWeChat\Kernel\Exceptions\BadRequestException $e) { abort(400, 'Invalid WeChat callback'); }
|
||
|
|
}
|
||
|
|
}
|