Skip to content

Commit

Permalink
Move listed rooms to API v4
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Mar 3, 2021
1 parent 685a463 commit aab5d94
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
'url' => '/api/{apiVersion}/listed-room',
'verb' => 'GET',
'requirements' => [
'apiVersion' => 'v3',
'apiVersion' => 'v4',
],
],
[
Expand Down
4 changes: 1 addition & 3 deletions lib/Controller/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,12 @@ public function getRooms(int $noStatusUpdate = 0): DataResponse {
* @return DataResponse
*/
public function getListedRooms(string $searchTerm = ''): DataResponse {
$event = new UserEvent($this->userId);

$rooms = $this->manager->getListedRoomsForUser($this->userId, $searchTerm);

$return = [];
foreach ($rooms as $room) {
try {
$return[] = $this->formatRoomV2andV3($room, null);
$return[] = $this->formatRoom($room, null);
} catch (RoomNotFoundException $e) {
} catch (\RuntimeException $e) {
}
Expand Down
22 changes: 11 additions & 11 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,59 +139,59 @@ public function tearDown() {
}

/**
* @Then /^user "([^"]*)" cannot find any listed rooms(?: \((v3)\))?$/
* @Then /^user "([^"]*)" cannot find any listed rooms \((v4)\)$/
*
* @param string $user
* @param string $apiVersion
*/
public function userCannotFindAnyListedRooms($user, $apiVersion = 'v3') {
public function userCannotFindAnyListedRooms(string $user, string $apiVersion) {
$this->userCanFindListedRoomsWithTerm($user, '', $apiVersion, null);
}

/**
* @Then /^user "([^"]*)" cannot find any listed rooms with (\d+)(?: \((v3)\))?$/
* @Then /^user "([^"]*)" cannot find any listed rooms with (\d+) \((v4)\)$/
*
* @param string $user
* @param int $statusCode
* @param string $apiVersion
*/
public function userCannotFindAnyListedRoomsWithStatus($user, $statusCode, $apiVersion = 'v3') {
public function userCannotFindAnyListedRoomsWithStatus(string $user, int $statusCode, string $apiVersion) {
$this->setCurrentUser($user);
$this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room');
$this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/listed-room');
$this->assertStatusCode($this->response, $statusCode);
}

/**
* @Then /^user "([^"]*)" cannot find any listed rooms with term "([^"]*)"(?: \((v3)\))?$/
* @Then /^user "([^"]*)" cannot find any listed rooms with term "([^"]*)" \((v4)\)$/
*
* @param string $user
* @param string $term
* @param string $apiVersion
*/
public function userCannotFindAnyListedRoomsWithTerm($user, $term, $apiVersion = 'v3') {
public function userCannotFindAnyListedRoomsWithTerm(string $user, string $term, string $apiVersion) {
$this->userCanFindListedRoomsWithTerm($user, $term, $apiVersion, null);
}

/**
* @Then /^user "([^"]*)" can find listed rooms(?: \((v3)\))?$/
* @Then /^user "([^"]*)" can find listed rooms \((v4)\)$/
*
* @param string $user
* @param string $apiVersion
* @param TableNode|null $formData
*/
public function userCanFindListedRooms($user, $apiVersion = 'v3', TableNode $formData = null) {
public function userCanFindListedRooms(string $user, string $apiVersion, TableNode $formData = null) {
$this->userCanFindListedRoomsWithTerm($user, '', $apiVersion, $formData);
}

/**
* @Then /^user "([^"]*)" can find listed rooms with term "([^"]*)"(?: \((v3)\))?$/
* @Then /^user "([^"]*)" can find listed rooms with term "([^"]*)" \((v4)\)$/
*
* @param string $user
* @param string $term
* @param string $apiVersion
* @param TableNode|null $formData
*/
public function userCanFindListedRoomsWithTerm($user, $term, $apiVersion = 'v3', TableNode $formData = null) {
public function userCanFindListedRoomsWithTerm(string $user, string $term, string $apiVersion, TableNode $formData = null) {
$this->setCurrentUser($user);
$suffix = '';
if ($term !== '') {
Expand Down
24 changes: 12 additions & 12 deletions tests/integration/features/conversation/find-listed.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Feature: conversation/find-listed
| roomName | public-room |
When user "creator" allows listing room "group-room" for "none" with 200
And user "creator" allows listing room "public-room" for "none" with 200
Then user "<user>" cannot find any listed rooms (v3)
Then user "<user>" cannot find any listed rooms (v4)
Examples:
| user |
| creator |
Expand All @@ -30,11 +30,11 @@ Feature: conversation/find-listed
| roomName | public-room |
When user "creator" allows listing room "group-room" for "users" with 200
And user "creator" allows listing room "public-room" for "users" with 200
Then user "regular-user" can find listed rooms (v3)
Then user "regular-user" can find listed rooms (v4)
| name | listable |
| group-room | 1 |
| public-room | 1 |
And user "user-guest@example.com" cannot find any listed rooms (v3)
And user "user-guest@example.com" cannot find any listed rooms (v4)

Scenario: All users can find all-listed rooms
Given user "creator" creates room "group-room"
Expand All @@ -45,11 +45,11 @@ Feature: conversation/find-listed
| roomName | public-room |
When user "creator" allows listing room "group-room" for "all" with 200
And user "creator" allows listing room "public-room" for "all" with 200
Then user "regular-user" can find listed rooms (v3)
Then user "regular-user" can find listed rooms (v4)
| name | listable |
| group-room | 2 |
| public-room | 2 |
And user "user-guest@example.com" can find listed rooms (v3)
And user "user-guest@example.com" can find listed rooms (v4)
| name | listable |
| group-room | 2 |
| public-room | 2 |
Expand All @@ -65,7 +65,7 @@ Feature: conversation/find-listed
And user "creator" allows listing room "public-room" for "users" with 200
When user "regular-user" joins room "group-room" with 200
And user "regular-user" joins room "public-room" with 200
Then user "regular-user" cannot find any listed rooms (v3)
Then user "regular-user" cannot find any listed rooms (v4)

Scenario: Participants cannot search for already joined listed rooms
Given user "creator" creates room "group-room"
Expand All @@ -78,7 +78,7 @@ Feature: conversation/find-listed
And user "creator" allows listing room "public-room" for "users" with 200
When user "regular-user" joins room "group-room" with 200
And user "regular-user" joins room "public-room" with 200
Then user "regular-user" cannot find any listed rooms (v3)
Then user "regular-user" cannot find any listed rooms (v4)

Scenario: Users can use search terms to find listed rooms
Given user "creator" creates room "group-room"
Expand All @@ -97,11 +97,11 @@ Feature: conversation/find-listed
And user "creator" allows listing room "public-room" for "all" with 200
And user "creator" allows listing room "group-the-cool-room" for "all" with 200
And user "creator" allows listing room "public-the-cool-room" for "all" with 200
Then user "regular-user" can find listed rooms with term "cool" (v3)
Then user "regular-user" can find listed rooms with term "cool" (v4)
| name | listable |
| group-the-cool-room | 2 |
| public-the-cool-room | 2 |
And user "user-guest@example.com" can find listed rooms with term "cool" (v3)
And user "user-guest@example.com" can find listed rooms with term "cool" (v4)
| name | listable |
| group-the-cool-room | 2 |
| public-the-cool-room | 2 |
Expand All @@ -111,8 +111,8 @@ Feature: conversation/find-listed
| roomType | 2 |
| roomName | group-room |
When user "creator" allows listing room "group-room" for "all" with 200
Then user "regular-user" cannot find any listed rooms with term "cool" (v3)
And user "user-guest@example.com" cannot find any listed rooms with term "cool" (v3)
Then user "regular-user" cannot find any listed rooms with term "cool" (v4)
And user "user-guest@example.com" cannot find any listed rooms with term "cool" (v4)

Scenario: Guest users without accounts cannot search for listed rooms
Given user "creator" creates room "public-room"
Expand All @@ -123,4 +123,4 @@ Feature: conversation/find-listed
| roomName | public-room-listed |
And user "creator" allows listing room "public-room-listed" for "all" with 200
When user "guest" joins room "public-room" with 200
Then user "guest" cannot find any listed rooms with 401 (v3)
Then user "guest" cannot find any listed rooms with 401 (v4)

0 comments on commit aab5d94

Please sign in to comment.