Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/Chat/AutoComplete/SearchPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ public function setContext(array $context): void {
* @since 13.0.0
*/
public function search($search, $limit, $offset, ISearchResult $searchResult) {
if ($this->room->getObjectType() === 'file') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw jsut for the record:
I did it the other way around, so normal users are listed before users which are not in the room yet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I did not think on that. Then maybe it would be better to restore the previous code and explicitly remove duplicated elements?

$usersWithFileAccess = $this->util->getUsersWithAccessFile($this->room->getObjectId());
if (!empty($usersWithFileAccess)) {
$this->searchUsers($search, $usersWithFileAccess, $searchResult);
}

return false;
}

$userIds = $this->room->getParticipantUserIds();
if ($this->room->getType() === Room::ONE_TO_ONE_CALL
Expand All @@ -76,13 +84,6 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
// FIXME Handle guests
$this->searchUsers($search, $userIds, $searchResult);

if ($this->room->getObjectType() === 'file') {
$usersWithFileAccess = $this->util->getUsersWithAccessFile($this->room->getObjectId());
if (!empty($usersWithFileAccess)) {
$this->searchUsers($search, $usersWithFileAccess, $searchResult);
}
}

return false;
}

Expand Down
66 changes: 66 additions & 0 deletions tests/integration/features/chat/mentions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,69 @@ Feature: chat/mentions
And user "guest" joins room "public room" with 200
Then user "participant4" gets the following candidate mentions in room "public room" for "" with 404
And user "guest2" gets the following candidate mentions in room "public room" for "" with 404



Scenario: get mentions in a file room with no other joined participant
Given user "participant1" shares "welcome.txt" with user "participant2" with OCS 100
When user "participant1" gets the room for path "welcome.txt" with 200
And user "participant1" is participant of room "file welcome.txt room"
And user "participant2" is not participant of room "file welcome.txt room"
Then user "participant1" gets the following candidate mentions in room "file welcome.txt room" for "" with 200
| id | label | source |
| all | welcome.txt | calls |
| participant2 | participant2-displayname | users |
And user "participant2" gets the following candidate mentions in room "file welcome.txt room" for "" with 404

Scenario: get mentions in a file room
Given user "participant1" shares "welcome.txt" with user "participant2" with OCS 100
When user "participant1" gets the room for path "welcome.txt" with 200
And user "participant2" gets the room for path "welcome (2).txt" with 200
And user "participant1" is participant of room "file welcome (2).txt room"
And user "participant2" is participant of room "file welcome (2).txt room"
Then user "participant1" gets the following candidate mentions in room "file welcome (2).txt room" for "" with 200
| id | label | source |
| all | welcome.txt | calls |
| participant2 | participant2-displayname | users |
And user "participant2" gets the following candidate mentions in room "file welcome (2).txt room" for "" with 200
| id | label | source |
| all | welcome.txt | calls |
| participant1 | participant1-displayname | users |

Scenario: get matched mentions in a file room
Given user "participant1" shares "welcome.txt" with user "participant2" with OCS 100
When user "participant1" gets the room for path "welcome.txt" with 200
And user "participant2" gets the room for path "welcome (2).txt" with 200
And user "participant1" is participant of room "file welcome (2).txt room"
And user "participant2" is participant of room "file welcome (2).txt room"
Then user "participant1" gets the following candidate mentions in room "file welcome (2).txt room" for "part" with 200
| id | label | source |
| participant2 | participant2-displayname | users |
And user "participant2" gets the following candidate mentions in room "file welcome (2).txt room" for "part" with 200
| id | label | source |
| participant1 | participant1-displayname | users |

Scenario: get unmatched mentions in a file room
Given user "participant1" shares "welcome.txt" with user "participant2" with OCS 100
When user "participant1" gets the room for path "welcome.txt" with 200
And user "participant2" gets the room for path "welcome (2).txt" with 200
And user "participant1" is participant of room "file welcome (2).txt room"
And user "participant2" is participant of room "file welcome (2).txt room"
Then user "participant1" gets the following candidate mentions in room "file welcome (2).txt room" for "unknown" with 200
And user "participant2" gets the following candidate mentions in room "file welcome (2).txt room" for "unknown" with 200

Scenario: get mentions in a file room with a participant without access to the file
Given user "participant1" shares "welcome.txt" with user "participant2" with OCS 100
When user "participant1" gets the room for path "welcome.txt" with 200
And user "participant2" gets the room for path "welcome (2).txt" with 200
And user "participant1" is participant of room "file welcome (2).txt room"
And user "participant2" is participant of room "file welcome (2).txt room"
Then user "participant3" gets the following candidate mentions in room "file welcome (2).txt room" for "" with 404

Scenario: mention a participant with access to the file but not joined in a file room
Given user "participant1" shares "welcome.txt" with user "participant2" with OCS 100
And user "participant1" gets the room for path "welcome.txt" with 200
And user "participant1" is participant of room "file welcome.txt room"
And user "participant2" is not participant of room "file welcome.txt room"
When user "participant1" sends message "hi @participant2" to room "file welcome.txt room" with 201
Then user "participant2" is participant of room "file welcome.txt room"