Skip to content

Commit b855a1d

Browse files
nickvergessenbackportbot[bot]
authored andcommitted
fix(search): Include captions in message search
Signed-off-by: Joas Schilling <[email protected]>
1 parent 2359506 commit b855a1d

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

lib/Chat/ChatManager.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -956,11 +956,11 @@ public function searchForObjects(string $search, array $objectIds, string $verb
956956
*
957957
* @param string $search content to search for
958958
* @param string[] $objectIds Limit the search by object ids
959-
* @param string $verb Limit the verb of the comment
959+
* @param string[] $verbs Limit the verb of the comment
960960
* @return list<IComment>
961961
*/
962-
public function searchForObjectsWithFilters(string $search, array $objectIds, string $verb, ?\DateTimeImmutable $since, ?\DateTimeImmutable $until, ?string $actorType, ?string $actorId, int $offset, int $limit = 50): array {
963-
return $this->commentsManager->searchForObjectsWithFilters($search, 'chat', $objectIds, $verb, $since, $until, $actorType, $actorId, $offset, $limit);
962+
public function searchForObjectsWithFilters(string $search, array $objectIds, array $verbs, ?\DateTimeImmutable $since, ?\DateTimeImmutable $until, ?string $actorType, ?string $actorId, int $offset, int $limit = 50): array {
963+
return $this->commentsManager->searchForObjectsWithFilters($search, 'chat', $objectIds, $verbs, $since, $until, $actorType, $actorId, $offset, $limit);
964964
}
965965

966966
public function addConversationNotify(array $results, string $search, Room $room, Participant $participant): array {

lib/Chat/CommentsManager.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ public function retrieveReactionsByActor(string $actorType, string $actorId, arr
9999
* @param string $search content to search for
100100
* @param string $objectType Limit the search by object type
101101
* @param string[] $objectIds Limit the search by object ids
102-
* @param string $verb Limit the verb of the comment
102+
* @param string[] $verbs Limit the verb of the comment
103103
* @return list<IComment>
104104
*/
105-
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 {
105+
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 {
106106
$query = $this->dbConn->getQueryBuilder();
107107

108108
$query->select('*')
@@ -136,8 +136,8 @@ public function searchForObjectsWithFilters(string $search, string $objectType,
136136
if (!empty($objectIds)) {
137137
$query->andWhere($query->expr()->in('object_id', $query->createNamedParameter($objectIds, IQueryBuilder::PARAM_STR_ARRAY)));
138138
}
139-
if ($verb !== '') {
140-
$query->andWhere($query->expr()->eq('verb', $query->createNamedParameter($verb)));
139+
if (!empty($verbs)) {
140+
$query->andWhere($query->expr()->in('verb', $query->createNamedParameter($verbs, IQueryBuilder::PARAM_STR_ARRAY)));
141141
}
142142
if ($offset !== 0) {
143143
$query->setFirstResult($offset);

lib/Search/MessageSearch.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function performSearch(IUser $user, ISearchQuery $query, string $title, a
206206
$comments = $this->chatManager->searchForObjectsWithFilters(
207207
$query->getTerm(),
208208
array_keys($roomMap),
209-
ChatManager::VERB_MESSAGE,
209+
[ChatManager::VERB_MESSAGE, ChatManager::VERB_OBJECT_SHARED],
210210
$lowerTimeBoundary,
211211
$upperTimeBoundary,
212212
$actorType,

tests/integration/features/chat-2/search.feature

+9
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,28 @@ Feature: chat-2/search
2121
And user "participant1" adds user "participant2" to room "room2" with 200 (v4)
2222
And user "participant1" sends message "Message 1" to room "room1" with 201
2323
And user "participant1" sends message "Message 2" to room "room2" with 201
24+
When user "participant1" shares "welcome.txt" with room "room1"
25+
| talkMetaData | {"caption":"Message 3"} |
26+
Then user "participant1" sees the following messages in room "room1" with 200
27+
| room | actorType | actorId | actorDisplayName | message | messageParameters |
28+
| room1 | users | participant1 | participant1-displayname | Message 3 | "IGNORE" |
29+
| room1 | users | participant1 | participant1-displayname | Message 1 | [] |
2430
When user "participant2" searches for messages with "essa" in room "room1" with 200
2531
| title | subline | attributes.conversation | attributes.messageId |
32+
| participant1-displayname | Message 3 | room1 | Message 3 |
2633
| participant1-displayname | Message 1 | room1 | Message 1 |
2734
When user "participant2" searches for messages with "essa" in room "room2" with 200
2835
| title | subline | attributes.conversation | attributes.messageId |
2936
| participant1-displayname | Message 2 | room2 | Message 2 |
3037
When user "participant2" searches for messages with "conversation:ROOM(room1) essa" in room "room1" with 200
3138
| title | subline | attributes.conversation | attributes.messageId |
39+
| participant1-displayname | Message 3 | room1 | Message 3 |
3240
| participant1-displayname | Message 1 | room1 | Message 1 |
3341
When user "participant2" searches for messages in other rooms with "conversation:ROOM(room1) essa" in room "room1" with 200
3442
When user "participant2" searches for messages with "conversation:ROOM(room1) essa" in room "room2" with 200
3543
When user "participant2" searches for messages in other rooms with "conversation:ROOM(room1) essa" in room "room2" with 200
3644
| title | subline | attributes.conversation | attributes.messageId |
45+
| participant1-displayname | Message 3 | room1 | Message 3 |
3746
| participant1-displayname | Message 1 | room1 | Message 1 |
3847

3948
Scenario: Can not search when being blocked by the lobby

0 commit comments

Comments
 (0)