mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-15 06:06:10 +00:00
kick forever
This commit is contained in:
@@ -16,13 +16,12 @@ class DashboardRoomService
|
||||
$ownedRooms = $user
|
||||
->ownedRooms()
|
||||
->with([
|
||||
'activePlayers' => fn ($query) => $query
|
||||
'players' => fn ($query) => $query
|
||||
->select(['id', 'room_id', 'user_id', 'name', 'is_moderator', 'created_at'])
|
||||
->orderByDesc('is_moderator')
|
||||
->orderBy('created_at'),
|
||||
])
|
||||
->withCount('players')
|
||||
->withCount(['activePlayers as active_player_count'])
|
||||
->orderByRaw('closed_at IS NOT NULL')
|
||||
->orderByDesc('last_activity_at')
|
||||
->get();
|
||||
@@ -30,7 +29,6 @@ class DashboardRoomService
|
||||
$favoriteRooms = $user
|
||||
->favoriteRooms()
|
||||
->withCount('players')
|
||||
->withCount(['activePlayers as active_player_count'])
|
||||
->orderByRaw('closed_at IS NOT NULL')
|
||||
->orderByDesc('last_activity_at')
|
||||
->get();
|
||||
|
||||
@@ -20,7 +20,6 @@ class RoomPageService
|
||||
|
||||
$room->load([
|
||||
'players' => fn ($query) => $query
|
||||
->active()
|
||||
->select(['id', 'room_id', 'user_id', 'name', 'is_moderator', 'created_at'])
|
||||
->orderByDesc('is_moderator')
|
||||
->orderBy('created_at'),
|
||||
|
||||
@@ -80,7 +80,6 @@ class RoomParticipationService
|
||||
} else {
|
||||
$player->update([
|
||||
'last_seen_at' => now(),
|
||||
'inactive_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -150,16 +149,13 @@ class RoomParticipationService
|
||||
]);
|
||||
$change = RoomStateChange::PlayerJoined;
|
||||
} else {
|
||||
if ($player->inactive_at !== null) {
|
||||
$change = RoomStateChange::PlayerJoined;
|
||||
} elseif ($player->name !== $playerName) {
|
||||
if ($player->name !== $playerName) {
|
||||
$change = RoomStateChange::PlayerUpdated;
|
||||
}
|
||||
|
||||
$updates = [
|
||||
'name' => $playerName,
|
||||
'last_seen_at' => now(),
|
||||
'inactive_at' => null,
|
||||
];
|
||||
|
||||
if (
|
||||
@@ -282,14 +278,14 @@ class RoomParticipationService
|
||||
?User $user,
|
||||
?Player $currentPlayer,
|
||||
): void {
|
||||
$stateVersion = DB::transaction(function () use ($room, $player, $user, $currentPlayer): ?int {
|
||||
$stateVersion = DB::transaction(function () use ($room, $player, $user, $currentPlayer): int {
|
||||
$lockedRoom = Room::query()
|
||||
->lockForUpdate()
|
||||
->findOrFail($room->id);
|
||||
|
||||
$lockedCurrentPlayer = $currentPlayer === null
|
||||
? null
|
||||
: $lockedRoom->activePlayers()
|
||||
: $lockedRoom->players()
|
||||
->lockForUpdate()
|
||||
->find($currentPlayer->id);
|
||||
$isOwner = $user !== null && $lockedRoom->owner_id === $user->id;
|
||||
@@ -312,13 +308,7 @@ class RoomParticipationService
|
||||
403,
|
||||
);
|
||||
|
||||
if ($lockedPlayer->inactive_at !== null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$lockedPlayer->update([
|
||||
'inactive_at' => now(),
|
||||
]);
|
||||
$lockedPlayer->delete();
|
||||
$lockedRoom->update([
|
||||
'last_activity_at' => now(),
|
||||
'state_version' => $lockedRoom->state_version + 1,
|
||||
@@ -327,10 +317,6 @@ class RoomParticipationService
|
||||
return $lockedRoom->state_version;
|
||||
});
|
||||
|
||||
if ($stateVersion === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
RoomStateChanged::dispatch(
|
||||
$room->id,
|
||||
$stateVersion,
|
||||
|
||||
@@ -32,7 +32,6 @@ class RoomRealtimeStateService
|
||||
$room->refresh();
|
||||
$room->load([
|
||||
'players' => fn ($query) => $query
|
||||
->active()
|
||||
->select(['id', 'room_id', 'user_id', 'name', 'is_moderator', 'created_at'])
|
||||
->orderByDesc('is_moderator')
|
||||
->orderBy('created_at'),
|
||||
|
||||
Reference in New Issue
Block a user