修复普通定向发言公屏可见

This commit is contained in:
pllx
2026-04-27 14:43:43 +08:00
parent c0cb7f5ead
commit 2c8cb21206
3 changed files with 78 additions and 12 deletions
+5 -7
View File
@@ -26,9 +26,9 @@ class MessageSent implements ShouldBroadcastNow
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
* 创建消息广播事件实例。
*
* @param int $roomId 房间ID
* @param int $roomId 房间 ID
* @param array $message 发送的消息数据
*/
public function __construct(
@@ -39,8 +39,8 @@ class MessageSent implements ShouldBroadcastNow
/**
* 获取消息应广播到的频道。
*
* 公共消息走房间 Presence 频道;
* 定向消息 / 悄悄话只发给发送方与接收方的私有用户频道。
* 公共消息和普通定向发言走房间 Presence 频道;
* 悄悄话只发给发送方与接收方的私有用户频道。
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
@@ -78,9 +78,7 @@ class MessageSent implements ShouldBroadcastNow
*/
private function shouldBroadcastPrivately(): bool
{
$toUser = trim((string) ($this->message['to_user'] ?? ''));
return $toUser !== '' && $toUser !== '大家';
return (bool) ($this->message['is_secret'] ?? false);
}
/**