Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] fix(search): Include captions in message search #14551

Merged
merged 1 commit into from
Mar 3, 2025
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
6 changes: 3 additions & 3 deletions lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -956,11 +956,11 @@ public function searchForObjects(string $search, array $objectIds, string $verb
*
* @param string $search content to search for
* @param string[] $objectIds Limit the search by object ids
* @param string $verb Limit the verb of the comment
* @param string[] $verbs Limit the verb of the comment
* @return list<IComment>
*/
public function searchForObjectsWithFilters(string $search, array $objectIds, string $verb, ?\DateTimeImmutable $since, ?\DateTimeImmutable $until, ?string $actorType, ?string $actorId, int $offset, int $limit = 50): array {
return $this->commentsManager->searchForObjectsWithFilters($search, 'chat', $objectIds, $verb, $since, $until, $actorType, $actorId, $offset, $limit);
public function searchForObjectsWithFilters(string $search, array $objectIds, array $verbs, ?\DateTimeImmutable $since, ?\DateTimeImmutable $until, ?string $actorType, ?string $actorId, int $offset, int $limit = 50): array {
return $this->commentsManager->searchForObjectsWithFilters($search, 'chat', $objectIds, $verbs, $since, $until, $actorType, $actorId, $offset, $limit);
}

public function addConversationNotify(array $results, string $search, Room $room, Participant $participant): array {
Expand Down
8 changes: 4 additions & 4 deletions lib/Chat/CommentsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ public function retrieveReactionsByActor(string $actorType, string $actorId, arr
* @param string $search content to search for
* @param string $objectType Limit the search by object type
* @param string[] $objectIds Limit the search by object ids
* @param string $verb Limit the verb of the comment
* @param string[] $verbs Limit the verb of the comment
* @return list<IComment>
*/
public function searchForObjectsWithFilters(string $search, string $objectType, array $objectIds, string $verb, ?\DateTimeImmutable $since, ?\DateTimeImmutable $until, ?string $actorType, ?string $actorId, int $offset, int $limit = 50): array {
public function searchForObjectsWithFilters(string $search, string $objectType, array $objectIds, array $verbs, ?\DateTimeImmutable $since, ?\DateTimeImmutable $until, ?string $actorType, ?string $actorId, int $offset, int $limit = 50): array {
$query = $this->dbConn->getQueryBuilder();

$query->select('*')
Expand Down Expand Up @@ -136,8 +136,8 @@ public function searchForObjectsWithFilters(string $search, string $objectType,
if (!empty($objectIds)) {
$query->andWhere($query->expr()->in('object_id', $query->createNamedParameter($objectIds, IQueryBuilder::PARAM_STR_ARRAY)));
}
if ($verb !== '') {
$query->andWhere($query->expr()->eq('verb', $query->createNamedParameter($verb)));
if (!empty($verbs)) {
$query->andWhere($query->expr()->in('verb', $query->createNamedParameter($verbs, IQueryBuilder::PARAM_STR_ARRAY)));
}
if ($offset !== 0) {
$query->setFirstResult($offset);
Expand Down
2 changes: 1 addition & 1 deletion lib/Search/MessageSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function performSearch(IUser $user, ISearchQuery $query, string $title, a
$comments = $this->chatManager->searchForObjectsWithFilters(
$query->getTerm(),
array_keys($roomMap),
ChatManager::VERB_MESSAGE,
[ChatManager::VERB_MESSAGE, ChatManager::VERB_OBJECT_SHARED],
$lowerTimeBoundary,
$upperTimeBoundary,
$actorType,
Expand Down
9 changes: 9 additions & 0 deletions tests/integration/features/chat-2/search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,28 @@ Feature: chat-2/search
And user "participant1" adds user "participant2" to room "room2" with 200 (v4)
And user "participant1" sends message "Message 1" to room "room1" with 201
And user "participant1" sends message "Message 2" to room "room2" with 201
When user "participant1" shares "welcome.txt" with room "room1"
| talkMetaData | {"caption":"Message 3"} |
Then user "participant1" sees the following messages in room "room1" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters |
| room1 | users | participant1 | participant1-displayname | Message 3 | "IGNORE" |
| room1 | users | participant1 | participant1-displayname | Message 1 | [] |
When user "participant2" searches for messages with "essa" in room "room1" with 200
| title | subline | attributes.conversation | attributes.messageId |
| participant1-displayname | Message 3 | room1 | Message 3 |
| participant1-displayname | Message 1 | room1 | Message 1 |
When user "participant2" searches for messages with "essa" in room "room2" with 200
| title | subline | attributes.conversation | attributes.messageId |
| participant1-displayname | Message 2 | room2 | Message 2 |
When user "participant2" searches for messages with "conversation:ROOM(room1) essa" in room "room1" with 200
| title | subline | attributes.conversation | attributes.messageId |
| participant1-displayname | Message 3 | room1 | Message 3 |
| participant1-displayname | Message 1 | room1 | Message 1 |
When user "participant2" searches for messages in other rooms with "conversation:ROOM(room1) essa" in room "room1" with 200
When user "participant2" searches for messages with "conversation:ROOM(room1) essa" in room "room2" with 200
When user "participant2" searches for messages in other rooms with "conversation:ROOM(room1) essa" in room "room2" with 200
| title | subline | attributes.conversation | attributes.messageId |
| participant1-displayname | Message 3 | room1 | Message 3 |
| participant1-displayname | Message 1 | room1 | Message 1 |

Scenario: Can not search when being blocked by the lobby
Expand Down
Loading