Skip to content

Commit

Permalink
Merge pull request #14297 from nextcloud/bugfix/13378/archive-testing
Browse files Browse the repository at this point in the history
fix(dashboard): Hide archived conversations from dashboard unless mentioned
  • Loading branch information
nickvergessen authored Feb 6, 2025
2 parents 66117e0 + b41adee commit 20bd1c9
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 27 deletions.
22 changes: 13 additions & 9 deletions lib/Dashboard/TalkWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7):
return false;
}

if ($room->getCallFlag() !== Participant::FLAG_DISCONNECTED) {
return true;
}

$participant = $this->participantService->getParticipant($room, $userId);
$attendee = $participant->getAttendee();

if (!$attendee->isArchived() && $room->getCallFlag() !== Participant::FLAG_DISCONNECTED) {
return true;
}

if (($room->isFederatedConversation() && $attendee->getLastMentionMessage())
|| (!$room->isFederatedConversation() && $attendee->getLastMentionMessage() > $attendee->getLastReadMessage())) {
return true;
Expand Down Expand Up @@ -186,14 +186,18 @@ public function getItemsV2(string $userId, ?string $since = null, int $limit = 7
if ($room->getObjectType() === BreakoutRoom::PARENT_OBJECT_TYPE) {
continue;
}
$rooms[] = $room;

$participant = $this->participantService->getParticipant($room, $userId);
$attendee = $participant->getAttendee();
if ($room->getCallFlag() !== Participant::FLAG_DISCONNECTED) {
// Call in progress
$mentions[] = $room;
continue;

if (!$attendee->isArchived()) {
$rooms[] = $room;

if ($room->getCallFlag() !== Participant::FLAG_DISCONNECTED) {
// Call in progress
$mentions[] = $room;
continue;
}
}

if (($room->isFederatedConversation() && $attendee->getLastMentionMessage())
Expand Down
23 changes: 5 additions & 18 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ private function assertRooms(array $rooms, TableNode $formData, bool $shouldOrde
if (isset($expectedRoom['listable'])) {
$data['listable'] = (string)$room['listable'];
}
if (isset($expectedRoom['isArchived'])) {
$data['isArchived'] = (int)$room['isArchived'];
}
if (isset($expectedRoom['participantType'])) {
$data['participantType'] = (string)$room['participantType'];
}
Expand Down Expand Up @@ -5167,12 +5170,12 @@ public function userSetsMentionPermissionsOfTheRoom(string $user, string $identi
* @When /^user "([^"]*)" (unarchives|archives) room "([^"]*)" with (\d+) \((v4)\)$/
*
* @param string $user
* @param string $identifier
* @param string $action
* @param string $identifier
* @param int $statusCode
* @param string $apiVersion
*/
public function userArchivesConversation(string $user, string $identifier, string $action, int $statusCode, string $apiVersion): void {
public function userArchivesConversation(string $user, string $action, string $identifier, int $statusCode, string $apiVersion): void {
$httpMethod = 'POST';

if ($action === 'unarchives') {
Expand All @@ -5186,22 +5189,6 @@ public function userArchivesConversation(string $user, string $identifier, strin
$this->assertStatusCode($this->response, $statusCode);
}

/**
* @When /^user "([^"]*)" unarchives room "([^"]*)" with (\d+) \((v4)\)$/
*
* @param string $user
* @param string $identifier
* @param int $statusCode
* @param string $apiVersion
*/
public function userUnarchivesConversation(string $user, string $identifier, int $statusCode, string $apiVersion): void {
$this->setCurrentUser($user);
$this->sendRequest(
'DELETE', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/archive',
);
$this->assertStatusCode($this->response, $statusCode);
}

/**
* @param string $verb
* @param string $fullUrl
Expand Down
28 changes: 28 additions & 0 deletions tests/integration/features/conversation-1/archive.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Feature: conversation-1/archive
Background:
Given user "participant1" exists
Given user "participant2" exists

Scenario: Archiving and unarchiving
Given user "participant1" creates room "group room" (v4)
| roomType | 3 |
| roomName | room |
When user "participant1" creates room "one-to-one room" (v4)
| roomType | 1 |
| invite | participant2 |
And user "participant1" is participant of the following rooms (v4)
| id | type | participantType | isArchived |
| group room | 3 | 1 | 0 |
| one-to-one room | 1 | 1 | 0 |
And user "participant1" archives room "one-to-one room" with 200 (v4)
And user "participant1" archives room "group room" with 200 (v4)
And user "participant1" is participant of the following rooms (v4)
| id | type | participantType | isArchived |
| group room | 3 | 1 | 1 |
| one-to-one room | 1 | 1 | 1 |
And user "participant1" unarchives room "one-to-one room" with 200 (v4)
And user "participant1" unarchives room "group room" with 200 (v4)
And user "participant1" is participant of the following rooms (v4)
| id | type | participantType | isArchived |
| group room | 3 | 1 | 0 |
| one-to-one room | 1 | 1 | 0 |
14 changes: 14 additions & 0 deletions tests/integration/features/integration/dashboard.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ 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} | | |
And user "participant1" archives room "one-to-one room" with 200 (v4)
And user "participant1" archives room "group room" with 200 (v4)
And user "participant1" archives room "call room" with 200 (v4)
Then user "participant1" sees the following entries for dashboard widgets "spreed" (v1)
| title | subtitle | link | iconUrl | sinceId | overlayIconUrl |
| 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 |
| 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} | | |
And user "participant1" unarchives room "one-to-one room" with 200 (v4)
And user "participant1" unarchives room "group room" with 200 (v4)
And user "participant1" unarchives room "call room" with 200 (v4)
And user "participant2" set the message expiration to 3 of room "one-to-one room" with 200 (v4)
And user "participant2" sends message "Message 3" to room "one-to-one room" with 201
And user "participant2" set the message expiration to 3 of room "group room" with 200 (v4)
Expand Down

0 comments on commit 20bd1c9

Please sign in to comment.