From f4dfb327048adc3013eb67980c270a4e90ff595f Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Mon, 8 Sep 2025 17:12:18 +0200 Subject: [PATCH 1/3] fix(MessageSearch): add threadId attribute for thread messages Signed-off-by: Maksim Sukharev --- lib/Search/MessageSearch.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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()); From f052f43aee9635b676d94278086676bfccb77ba1 Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Mon, 8 Sep 2025 17:13:41 +0200 Subject: [PATCH 2/3] fix(SearchMessagesTab): route to thread from search results Signed-off-by: Maksim Sukharev --- .../RightSidebar/SearchMessages/SearchMessagesTab.vue | 3 +++ src/types/core.ts | 1 + 2 files changed, 4 insertions(+) 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 Date: Mon, 8 Sep 2025 18:42:28 +0200 Subject: [PATCH 3/3] test: add search result thread test Signed-off-by: Anna Larch --- .../features/bootstrap/FeatureContext.php | 6 ++++++ tests/integration/features/chat-4/search.feature | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 13454960148..cf09abae16c 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -2795,6 +2795,9 @@ protected function compareSearchResponse(?TableNode $formData = null, ?string $e if (isset($result['attributes.conversation'])) { $result['attributes.conversation'] = self::$identifierToToken[$result['attributes.conversation']]; } + if (isset($result['attributes.threadId'])) { + $result['attributes.threadId'] = self::$titleToThreadId[$result['attributes.threadId']]; + } if (isset($result['attributes.messageId'])) { $result['attributes.messageId'] = self::$textToMessageId[$result['attributes.messageId']]; } @@ -2815,6 +2818,9 @@ protected function compareSearchResponse(?TableNode $formData = null, ?string $e if (isset($actual['attributes']['messageId'])) { $compare['attributes.messageId'] = $actual['attributes']['messageId']; } + if (isset($actual['attributes']['threadId'])) { + $compare['attributes.threadId'] = $actual['attributes']['threadId']; + } return $compare; }, $results)); } diff --git a/tests/integration/features/chat-4/search.feature b/tests/integration/features/chat-4/search.feature index 4847b42e8be..1e7377aa5ea 100644 --- a/tests/integration/features/chat-4/search.feature +++ b/tests/integration/features/chat-4/search.feature @@ -21,12 +21,16 @@ 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 + And user "participant1" sends thread "Thread 1" with message "Thread 1" to room "room1" with 201 + And user "participant2" sends reply "Thread 1-1" on thread "Thread 1" to room "room1" 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 | [] | + | room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | + | room1 | users | participant1 | participant1-displayname | Message 3 | "IGNORE" | | + | room1 | users | participant2 | participant2-displayname | Thread 1-1 | [] | Thread 1 | + | room1 | users | participant1 | participant1-displayname | Thread 1 | [] | | + | 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 | @@ -44,6 +48,10 @@ Feature: chat-2/search | 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 "read" in room "room1" with 200 + | title | subline | attributes.conversation | attributes.threadId | attributes.messageId | + | participant2-displayname | Thread 1-1 | room1 | Thread 1 | Thread 1-1 | + | participant1-displayname | Thread 1 | room1 | Thread 1 | Thread 1 | Scenario: Can not search when being blocked by the lobby Given user "participant1" creates room "room" (v4)