避免座驾进房重复欢迎

This commit is contained in:
pllx
2026-04-30 11:12:50 +08:00
parent fc7930046d
commit 522eea72f6
2 changed files with 34 additions and 32 deletions
+4 -5
View File
@@ -196,12 +196,10 @@ class ChatController extends Controller
} }
// 统一走通用进场播报逻辑,管理员不再发送单独的特殊登录提示。 // 统一走通用进场播报逻辑,管理员不再发送单独的特殊登录提示。
[$text, $color] = $this->broadcast->buildEntryBroadcast($user);
$ridePresencePayload = $this->rideService->buildPresencePayload($user); $ridePresencePayload = $this->rideService->buildPresencePayload($user);
// 座驾优先级高于会员进场主题,避免同一用户进房时同时播放两套全屏特效。 if (! $ridePresencePayload) {
$vipPresencePayload = $ridePresencePayload [$text, $color] = $this->broadcast->buildEntryBroadcast($user);
? [] $vipPresencePayload = $this->broadcast->buildVipPresencePayload($user, 'join');
: $this->broadcast->buildVipPresencePayload($user, 'join');
$generalWelcomeMsg = [ $generalWelcomeMsg = [
'id' => $this->chatState->nextMessageId($id), 'id' => $this->chatState->nextMessageId($id),
@@ -235,6 +233,7 @@ class ChatController extends Controller
if (! empty($vipPresencePayload['presence_effect'])) { if (! empty($vipPresencePayload['presence_effect'])) {
broadcast(new \App\Events\EffectBroadcast($id, $vipPresencePayload['presence_effect'], $user->username))->toOthers(); broadcast(new \App\Events\EffectBroadcast($id, $vipPresencePayload['presence_effect'], $user->username))->toOthers();
} }
}
if ($ridePresencePayload) { if ($ridePresencePayload) {
$rideWelcomeMsg = [ $rideWelcomeMsg = [
+3
View File
@@ -1128,8 +1128,10 @@ class ChatControllerTest extends TestCase
$response->assertOk(); $response->assertOk();
$history = collect($response->viewData('historyMessages')); $history = collect($response->viewData('historyMessages'));
$rideMessage = $history->first(fn (array $message): bool => ($message['welcome_kind'] ?? '') === 'ride_presence'); $rideMessage = $history->first(fn (array $message): bool => ($message['welcome_kind'] ?? '') === 'ride_presence');
$entryBroadcast = $history->first(fn (array $message): bool => ($message['welcome_kind'] ?? '') === 'entry_broadcast');
$this->assertNotNull($rideMessage); $this->assertNotNull($rideMessage);
$this->assertNull($entryBroadcast);
$this->assertSame('座驾播报', $rideMessage['from_user']); $this->assertSame('座驾播报', $rideMessage['from_user']);
$this->assertSame('j35', $rideMessage['ride_key']); $this->assertSame('j35', $rideMessage['ride_key']);
$this->assertSame("{$user->username} 乘坐【歼-35测试座驾】闪亮登场", $rideMessage['effect_title']); $this->assertSame("{$user->username} 乘坐【歼-35测试座驾】闪亮登场", $rideMessage['effect_title']);
@@ -1217,6 +1219,7 @@ class ChatControllerTest extends TestCase
$this->assertStringContainsString($user->username, $rideMessage['content']); $this->assertStringContainsString($user->username, $rideMessage['content']);
$this->assertSame('99a', $response->viewData('initialRideEffect')); $this->assertSame('99a', $response->viewData('initialRideEffect'));
$this->assertSame("用户 {$user->username} · 部门 战备部 · 职务 🛡️ 试飞官 · 会员 👑 至尊会员", $response->viewData('initialRideEffectOptions')['effect_user_info']); $this->assertSame("用户 {$user->username} · 部门 战备部 · 职务 🛡️ 试飞官 · 会员 👑 至尊会员", $response->viewData('initialRideEffectOptions')['effect_user_info']);
$this->assertNull($response->viewData('initialWelcomeMessage'));
$this->assertNull($response->viewData('initialPresenceTheme')); $this->assertNull($response->viewData('initialPresenceTheme'));
} }