Skip to content

Commit

Permalink
fix(breakoutrooms): Hide breakout rooms from dashboard items
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Apr 10, 2024
1 parent 910087c commit 09bfcbf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
5 changes: 3 additions & 2 deletions lib/Dashboard/TalkWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ public function getItemsV2(string $userId, ?string $since = null, int $limit = 7
$rooms = [];
$mentions = [];
foreach ($allRooms as $room) {
if ($room->getObjectType() !== BreakoutRoom::PARENT_OBJECT_TYPE) {
$rooms[] = $room;
if ($room->getObjectType() === BreakoutRoom::PARENT_OBJECT_TYPE) {
continue;
}
$rooms[] = $room;

$participant = $this->participantService->getParticipant($room, $userId);
$attendee = $participant->getAttendee();
Expand Down
18 changes: 12 additions & 6 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2322,7 +2322,7 @@ public function userGetsDashboardWidgets($user, $apiVersion = 'v1', TableNode $f
}

/**
* @Then /^user "([^"]*)" sees the following entries for dashboard widgets "([^"]*)"(?: \((v1)\))$/
* @Then /^user "([^"]*)" sees the following entries for dashboard widgets "([^"]*)"(?: \((v1|v2)\))$/
*
* @param string $user
* @param string $widgetId
Expand All @@ -2339,24 +2339,30 @@ public function userGetsDashboardWidgetItems($user, $widgetId, $apiVersion = 'v1
Assert::assertArrayHasKey($widgetId, $data);
$expectedItems = $formData->getColumnsHash();

if ($apiVersion === 'v1') {
$actualItems = $data[$widgetId];
} else {
$actualItems = $data[$widgetId]['items'];
}

if (empty($expectedItems)) {
Assert::assertEmpty($data[$widgetId]);
Assert::assertEmpty($actualItems);
return;
}

Assert::assertCount(count($expectedItems), $data[$widgetId]);
Assert::assertCount(count($expectedItems), $actualItems);

foreach ($expectedItems as $key => $item) {
$token = self::$identifierToToken[$item['link']];
$item['link'] = $this->baseUrl . 'index.php/call/' . $token;
$item['iconUrl'] = str_replace('{$BASE_URL}', $this->baseUrl, $item['iconUrl']);
$item['iconUrl'] = str_replace('{token}', $token, $item['iconUrl']);

Assert::assertMatchesRegularExpression('/\?v=\w{8}$/', $data[$widgetId][$key]['iconUrl']);
preg_match('/(?<version>\?v=\w{8})$/', $data[$widgetId][$key]['iconUrl'], $matches);
Assert::assertMatchesRegularExpression('/\?v=\w{8}$/', $actualItems[$key]['iconUrl']);
preg_match('/(?<version>\?v=\w{8})$/', $actualItems[$key]['iconUrl'], $matches);
$item['iconUrl'] = str_replace('{version}', $matches['version'], $item['iconUrl']);

Assert::assertEquals($item, $data[$widgetId][$key], 'Wrong details for item #' . $key);
Assert::assertEquals($item, $actualItems[$key], 'Wrong details for item #' . $key);
}
}

Expand Down
7 changes: 7 additions & 0 deletions tests/integration/features/integration/dashboard.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Feature: integration/dashboard
Scenario: User gets the dashboard widget content
When user "participant1" sees the following entries for dashboard widgets "spreed" (v1)
| title | subtitle | link | iconUrl |
When user "participant1" sees the following entries for dashboard widgets "spreed" (v2)
| title | subtitle | link | iconUrl |
Given user "participant2" creates room "one-to-one room" (v4)
| roomType | 1 |
| invite | participant1 |
Expand Down Expand Up @@ -40,3 +42,8 @@ Feature: integration/dashboard
| call room | Call in progress | call room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |
| group room | You were mentioned | group room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |
| participant2-displayname | Hello | one-to-one room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |
Then user "participant1" sees the following entries for dashboard widgets "spreed" (v2)
| title | subtitle | link | iconUrl | sinceId | overlayIconUrl |
| call room | Call in progress | call room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |
| group room | You were mentioned | group room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |
| participant2-displayname | Hello | one-to-one room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |

0 comments on commit 09bfcbf

Please sign in to comment.