From 417cc743866fb213a861e2b76e36371be09e155a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 4 Jan 2022 10:36:52 +0100 Subject: [PATCH] Add attributes in search results Signed-off-by: Joas Schilling --- lib/Search/ConversationSearch.php | 6 +++++- lib/Search/MessageSearch.php | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Search/ConversationSearch.php b/lib/Search/ConversationSearch.php index bde25c053b8..8638ff63e54 100644 --- a/lib/Search/ConversationSearch.php +++ b/lib/Search/ConversationSearch.php @@ -141,7 +141,7 @@ public function search(IUser $user, ISearchQuery $query): SearchResult { $iconClass = 'conversation-icon icon-contacts'; } - $result[] = new SearchResultEntry( + $entry = new SearchResultEntry( $icon, $room->getDisplayName($user->getUID()), '', @@ -149,6 +149,10 @@ public function search(IUser $user, ISearchQuery $query): SearchResult { $iconClass, true ); + + $entry->addAttribute('conversation', $room->getToken()); + + $result[] = $entry; } return SearchResult::complete( diff --git a/lib/Search/MessageSearch.php b/lib/Search/MessageSearch.php index 04fc4b8d23d..cd442e8cfbc 100644 --- a/lib/Search/MessageSearch.php +++ b/lib/Search/MessageSearch.php @@ -206,7 +206,7 @@ protected function commentToSearchResultEntry(Room $room, IUser $user, IComment $subline = '{user}'; } - return new SearchResultEntry( + $entry = new SearchResultEntry( $iconUrl, str_replace( ['{user}', '{conversation}'], @@ -218,5 +218,10 @@ protected function commentToSearchResultEntry(Room $room, IUser $user, IComment 'icon-talk', // $iconClass, true ); + + $entry->addAttribute('conversation', $room->getToken()); + $entry->addAttribute('messageId', $comment->getId()); + + return $entry; } }