加固房间准入与消息广播边界
This commit is contained in:
+9
-3
@@ -8,9 +8,15 @@ Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
|
||||
|
||||
// 聊天室房间 Presence Channel 鉴权与成员信息抓取
|
||||
Broadcast::channel('room.{roomId}', function ($user, $roomId) {
|
||||
// 这里未来可以增加判断:比如该房间是否被锁定,或者该用户是否在此房间的黑名单中
|
||||
// 凡是通过了这个判断的人(返回一个数组),他就会成功建立 WebSocket,
|
||||
// 且他的这个数组信息会被 Reverb 推送给这个房间内的所有其他人 (joining / here 事件)。
|
||||
$room = \App\Models\Room::find($roomId);
|
||||
if (! $room || ! $room->canUserEnter($user)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$chatState = app(\App\Services\ChatStateService::class);
|
||||
if (! $chatState->isUserInRoom((int) $roomId, $user->username)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$superLevel = (int) \App\Models\Sysparam::getValue('superlevel', '100');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user