Browse Source

Merge pull request #8028 from nextcloud/bugfix/8025/recursion-with-lobby-timer-expiring

Recursion with lobby timer expiring
pull/8037/head
Joas Schilling 3 years ago
committed by GitHub
parent
commit
5430eeeffb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      lib/Room.php
  2. 2
      lib/Service/RoomService.php
  3. 39
      tests/integration/features/bootstrap/FeatureContext.php
  4. 19
      tests/integration/features/conversation/lobby.feature

16
lib/Room.php

@ -295,8 +295,10 @@ class Room {
$this->messageExpiration = $messageExpiration;
}
public function getLobbyState(): int {
$this->validateTimer();
public function getLobbyState(bool $validateTime = true): int {
if ($validateTime) {
$this->validateTimer();
}
return $this->lobbyState;
}
@ -304,8 +306,10 @@ class Room {
$this->lobbyState = $lobbyState;
}
public function getLobbyTimer(): ?\DateTime {
$this->validateTimer();
public function getLobbyTimer(bool $validateTime = true): ?\DateTime {
if ($validateTime) {
$this->validateTimer();
}
return $this->lobbyTimer;
}
@ -315,7 +319,9 @@ class Room {
protected function validateTimer(): void {
if ($this->lobbyTimer !== null && $this->lobbyTimer < $this->timeFactory->getDateTime()) {
Server::get(RoomService::class)->setLobby($this, Webinary::LOBBY_NONE, null, true);
/** @var RoomService $roomService */
$roomService = Server::get(RoomService::class);
$roomService->setLobby($this, Webinary::LOBBY_NONE, null, true);
}
}

2
lib/Service/RoomService.php

@ -279,7 +279,7 @@ class RoomService {
* @return bool True when the change was valid, false otherwise
*/
public function setLobby(Room $room, int $newState, ?\DateTime $dateTime, bool $timerReached = false): bool {
$oldState = $room->getLobbyState();
$oldState = $room->getLobbyState(false);
if (!in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) {
return false;

39
tests/integration/features/bootstrap/FeatureContext.php

@ -336,6 +336,9 @@ class FeatureContext implements Context, SnippetAcceptingContext {
if (isset($expectedRoom['callFlag'])) {
$data['callFlag'] = (int) $room['callFlag'];
}
if (isset($expectedRoom['lobbyState'])) {
$data['lobbyState'] = (int) $room['lobbyState'];
}
if (isset($expectedRoom['attendeePin'])) {
$data['attendeePin'] = $room['attendeePin'] ? '**PIN**' : '';
}
@ -1135,6 +1138,33 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$this->assertStatusCode($this->response, $statusCode);
}
/**
* @When /^user "([^"]*)" sets lobby state for room "([^"]*)" to "([^"]*)" for (\d+) seconds with (\d+) \((v4)\)$/
*
* @param string $user
* @param string $identifier
* @param string $lobbyStateString
* @param int $lobbyTimer
* @param int $statusCode
* @param string $apiVersion
*/
public function userSetsLobbyStateAndTimerForRoom(string $user, string $identifier, string $lobbyStateString, int $lobbyTimer, int $statusCode, string $apiVersion): void {
if ($lobbyStateString === 'no lobby') {
$lobbyState = 0;
} elseif ($lobbyStateString === 'non moderators') {
$lobbyState = 1;
} else {
Assert::fail('Invalid lobby state');
}
$this->setCurrentUser($user);
$this->sendRequest(
'PUT', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/webinar/lobby',
new TableNode([['state', $lobbyState], ['timer', time() + $lobbyTimer]])
);
$this->assertStatusCode($this->response, $statusCode);
}
/**
* @When /^user "([^"]*)" sets SIP state for room "([^"]*)" to "([^"]*)" with (\d+) \((v4)\)$/
*
@ -2662,7 +2692,14 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
* @When wait for :seconds seconds?
* @When wait for :seconds second
*/
public function waitForXSecond($seconds): void {
sleep($seconds);
}
/**
* @When wait for :seconds seconds
*/
public function waitForXSeconds($seconds): void {
sleep($seconds);

19
tests/integration/features/conversation/lobby.feature

@ -249,3 +249,22 @@ Feature: conversation/lobby
And user "guest2" is participant of room "room" (v4)
| name | description | type | participantType | lastMessage |
| room | the description | 3 | 4 | |
# Not all the values are checked in the test, only the most relevant ones
Scenario: Make sure resetting the lobby timer works on the room list
Given user "participant1" creates room "room" (v4)
| roomType | 3 |
| roomName | room |
Then user "participant1" is participant of room "room" (v4)
| name | lobbyState |
| room | 0 |
When user "participant1" sets lobby state for room "room" to "non moderators" with 200 (v4)
Then user "participant1" is participant of room "room" (v4)
| name | lobbyState |
| room | 1 |
When user "participant1" sets lobby state for room "room" to "non moderators" for 5 seconds with 200 (v4)
When wait for 10 second
Then user "participant1" is participant of room "room" (v4)
| name | lobbyState |
| room | 0 |
Loading…
Cancel
Save