diff --git a/lib/Search/MessageSearch.php b/lib/Search/MessageSearch.php index bc87c126c38..3e5f3feac4c 100644 --- a/lib/Search/MessageSearch.php +++ b/lib/Search/MessageSearch.php @@ -19,7 +19,9 @@ use OCA\Talk\Model\Attendee; use OCA\Talk\Room; use OCA\Talk\Service\ParticipantService; +use OCA\Talk\Service\ThreadService; use OCA\Talk\Webinary; +use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Comments\IComment; use OCP\IL10N; @@ -50,6 +52,7 @@ public function __construct( protected IL10N $l, protected Config $talkConfig, protected IUserSession $userSession, + protected ThreadService $threadService, ) { } @@ -282,6 +285,12 @@ protected function commentToSearchResultEntry(Room $room, IUser $user, IComment } } + $threadId = (int)$comment->getTopmostParentId() ?: (int)$comment->getId(); + try { + $thread = $this->threadService->findByThreadId($room->getId(), $threadId); + } catch (DoesNotExistException) { + $thread = null; + } $entry = new SearchResultEntry( $iconUrl, str_replace( @@ -290,13 +299,18 @@ protected function commentToSearchResultEntry(Room $room, IUser $user, IComment $subline ), $messageStr, - $this->url->linkToRouteAbsolute('spreed.Page.showCall', ['token' => $room->getToken()]) . '#message_' . $comment->getId(), + $this->url->linkToRouteAbsolute('spreed.Page.showCall', ['token' => $room->getToken()]) + . ($thread !== null ? '?threadId=' . $thread->getId() : '') + . '#message_' . $comment->getId(), 'icon-talk', // $iconClass, true ); $entry->addAttribute('conversation', $room->getToken()); $entry->addAttribute('messageId', $comment->getId()); + if ($thread !== null) { + $entry->addAttribute('threadId', (string)$thread->getId()); + } $entry->addAttribute('actorType', $comment->getActorType()); $entry->addAttribute('actorId', $comment->getActorId()); $entry->addAttribute('timestamp', '' . $comment->getCreationDateTime()->getTimestamp()); diff --git a/src/components/RightSidebar/SearchMessages/SearchMessagesTab.vue b/src/components/RightSidebar/SearchMessages/SearchMessagesTab.vue index db4cc714cb4..ffaa67366d5 100644 --- a/src/components/RightSidebar/SearchMessages/SearchMessagesTab.vue +++ b/src/components/RightSidebar/SearchMessages/SearchMessagesTab.vue @@ -219,12 +219,15 @@ async function fetchSearchResults(isNew = true): Promise { } searchResults.value = searchResults.value.concat(entries.map((entry: UnifiedSearchResultEntry) => { + const threadId = (entry.attributes.threadId !== entry.attributes.messageId) ? entry.attributes.threadId : undefined + return { ...entry, to: { name: 'conversation', hash: `#message_${entry.attributes.messageId}`, params: { token: entry.attributes.conversation }, + query: { threadId }, }, } })) diff --git a/src/types/core.ts b/src/types/core.ts index d7a3abb8496..e2253a3e10f 100644 --- a/src/types/core.ts +++ b/src/types/core.ts @@ -95,6 +95,7 @@ export type AutocompleteResponse = ApiResponse