Skip to content

Commit 20bd1c9

Browse files
Merge pull request #14297 from nextcloud/bugfix/13378/archive-testing
fix(dashboard): Hide archived conversations from dashboard unless mentioned
2 parents 66117e0 + b41adee commit 20bd1c9

File tree

4 files changed

+60
-27
lines changed

4 files changed

+60
-27
lines changed

lib/Dashboard/TalkWidget.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7):
142142
return false;
143143
}
144144

145-
if ($room->getCallFlag() !== Participant::FLAG_DISCONNECTED) {
146-
return true;
147-
}
148-
149145
$participant = $this->participantService->getParticipant($room, $userId);
150146
$attendee = $participant->getAttendee();
151147

148+
if (!$attendee->isArchived() && $room->getCallFlag() !== Participant::FLAG_DISCONNECTED) {
149+
return true;
150+
}
151+
152152
if (($room->isFederatedConversation() && $attendee->getLastMentionMessage())
153153
|| (!$room->isFederatedConversation() && $attendee->getLastMentionMessage() > $attendee->getLastReadMessage())) {
154154
return true;
@@ -186,14 +186,18 @@ public function getItemsV2(string $userId, ?string $since = null, int $limit = 7
186186
if ($room->getObjectType() === BreakoutRoom::PARENT_OBJECT_TYPE) {
187187
continue;
188188
}
189-
$rooms[] = $room;
190189

191190
$participant = $this->participantService->getParticipant($room, $userId);
192191
$attendee = $participant->getAttendee();
193-
if ($room->getCallFlag() !== Participant::FLAG_DISCONNECTED) {
194-
// Call in progress
195-
$mentions[] = $room;
196-
continue;
192+
193+
if (!$attendee->isArchived()) {
194+
$rooms[] = $room;
195+
196+
if ($room->getCallFlag() !== Participant::FLAG_DISCONNECTED) {
197+
// Call in progress
198+
$mentions[] = $room;
199+
continue;
200+
}
197201
}
198202

199203
if (($room->isFederatedConversation() && $attendee->getLastMentionMessage())

tests/integration/features/bootstrap/FeatureContext.php

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,9 @@ private function assertRooms(array $rooms, TableNode $formData, bool $shouldOrde
523523
if (isset($expectedRoom['listable'])) {
524524
$data['listable'] = (string)$room['listable'];
525525
}
526+
if (isset($expectedRoom['isArchived'])) {
527+
$data['isArchived'] = (int)$room['isArchived'];
528+
}
526529
if (isset($expectedRoom['participantType'])) {
527530
$data['participantType'] = (string)$room['participantType'];
528531
}
@@ -5167,12 +5170,12 @@ public function userSetsMentionPermissionsOfTheRoom(string $user, string $identi
51675170
* @When /^user "([^"]*)" (unarchives|archives) room "([^"]*)" with (\d+) \((v4)\)$/
51685171
*
51695172
* @param string $user
5170-
* @param string $identifier
51715173
* @param string $action
5174+
* @param string $identifier
51725175
* @param int $statusCode
51735176
* @param string $apiVersion
51745177
*/
5175-
public function userArchivesConversation(string $user, string $identifier, string $action, int $statusCode, string $apiVersion): void {
5178+
public function userArchivesConversation(string $user, string $action, string $identifier, int $statusCode, string $apiVersion): void {
51765179
$httpMethod = 'POST';
51775180

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

5189-
/**
5190-
* @When /^user "([^"]*)" unarchives room "([^"]*)" with (\d+) \((v4)\)$/
5191-
*
5192-
* @param string $user
5193-
* @param string $identifier
5194-
* @param int $statusCode
5195-
* @param string $apiVersion
5196-
*/
5197-
public function userUnarchivesConversation(string $user, string $identifier, int $statusCode, string $apiVersion): void {
5198-
$this->setCurrentUser($user);
5199-
$this->sendRequest(
5200-
'DELETE', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/archive',
5201-
);
5202-
$this->assertStatusCode($this->response, $statusCode);
5203-
}
5204-
52055192
/**
52065193
* @param string $verb
52075194
* @param string $fullUrl
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Feature: conversation-1/archive
2+
Background:
3+
Given user "participant1" exists
4+
Given user "participant2" exists
5+
6+
Scenario: Archiving and unarchiving
7+
Given user "participant1" creates room "group room" (v4)
8+
| roomType | 3 |
9+
| roomName | room |
10+
When user "participant1" creates room "one-to-one room" (v4)
11+
| roomType | 1 |
12+
| invite | participant2 |
13+
And user "participant1" is participant of the following rooms (v4)
14+
| id | type | participantType | isArchived |
15+
| group room | 3 | 1 | 0 |
16+
| one-to-one room | 1 | 1 | 0 |
17+
And user "participant1" archives room "one-to-one room" with 200 (v4)
18+
And user "participant1" archives room "group room" with 200 (v4)
19+
And user "participant1" is participant of the following rooms (v4)
20+
| id | type | participantType | isArchived |
21+
| group room | 3 | 1 | 1 |
22+
| one-to-one room | 1 | 1 | 1 |
23+
And user "participant1" unarchives room "one-to-one room" with 200 (v4)
24+
And user "participant1" unarchives room "group room" with 200 (v4)
25+
And user "participant1" is participant of the following rooms (v4)
26+
| id | type | participantType | isArchived |
27+
| group room | 3 | 1 | 0 |
28+
| one-to-one room | 1 | 1 | 0 |

tests/integration/features/integration/dashboard.feature

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ Feature: integration/dashboard
5252
| call room | Call in progress | call room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |
5353
| group room | You were mentioned | group room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |
5454
| participant2-displayname | Hello | one-to-one room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |
55+
And user "participant1" archives room "one-to-one room" with 200 (v4)
56+
And user "participant1" archives room "group room" with 200 (v4)
57+
And user "participant1" archives room "call room" with 200 (v4)
58+
Then user "participant1" sees the following entries for dashboard widgets "spreed" (v1)
59+
| title | subtitle | link | iconUrl | sinceId | overlayIconUrl |
60+
| group room | You were mentioned | group room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |
61+
| participant2-displayname | Hello | one-to-one room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |
62+
Then user "participant1" sees the following entries for dashboard widgets "spreed" (v2)
63+
| title | subtitle | link | iconUrl | sinceId | overlayIconUrl |
64+
| group room | You were mentioned | group room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |
65+
| participant2-displayname | Hello | one-to-one room | {$BASE_URL}ocs/v2.php/apps/spreed/api/v1/room/{token}/avatar{version} | | |
66+
And user "participant1" unarchives room "one-to-one room" with 200 (v4)
67+
And user "participant1" unarchives room "group room" with 200 (v4)
68+
And user "participant1" unarchives room "call room" with 200 (v4)
5569
And user "participant2" set the message expiration to 3 of room "one-to-one room" with 200 (v4)
5670
And user "participant2" sends message "Message 3" to room "one-to-one room" with 201
5771
And user "participant2" set the message expiration to 3 of room "group room" with 200 (v4)

0 commit comments

Comments
 (0)