帖子内容风险检查

This commit is contained in:
2025-12-26 15:51:10 +08:00
parent 00c4843b8b
commit 42315c0f7d
2 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ class PostController extends BaseController
$res = $this->service->serviceStore($request, $data);
return $this->success($res, '创建成功');
} catch (\Throwable $e) {
return $this->error($e->getMessage().$e->getLine().$e->getFile());
return $this->error($e->getMessage());
}
}
+13
View File
@@ -110,6 +110,19 @@ class PostService
public function beforeServiceStore($data, Request $request)
{
$data['user_id'] = $request->user->uid;;
//安全检查
$wechat = new WechatService();
$tokenData = $wechat->getMiniAccessToken();
$access_token = $tokenData['access_token'];
$user = User::where('id', $data['user_id'])->first();
if(empty($user)){
throw new \Exception('用户不存在');
}
$tokenData = $wechat->checkText($data['content'], $user['openid'], $access_token, 2);
$user = User::where('id', $data['user_id'])->first();
if($user->is_release == 0){
$staff = UserStaff::where('name',$user->name)->where('sn',$user->sn)->first();