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

Include chat metadata in unified search entry #6723

Closed
thisIsTheFoxe opened this issue Dec 17, 2021 · 2 comments · Fixed by #6743
Closed

Include chat metadata in unified search entry #6723

thisIsTheFoxe opened this issue Dec 17, 2021 · 2 comments · Fixed by #6743

Comments

@thisIsTheFoxe
Copy link

Is your feature request related to a problem? Please describe.
Implementing unified search on clients as it is now requires parsing the { "entries": [ { "resourceUrl": ... to get the relevant data. This is a very unclean solution.

Describe the solution you'd like
As was mentioned in 2nd the linked issue, the files provider uses the attributes key to provide additional metadata. A similar approach could be used here, where roomToken would be the most important, but other info could be useful as well.
Example: > http://localhost/ocs/v2.php/search/providers/talk-message/search?format=json&term=test

"entries": [
  {
    "thumbnailUrl": "http://localhost/avatar/admin/64",
    "title": "admin in Test",
    "subline": "test message",
    "resourceUrl": "http://localhost/call/abc123#message_42",
    "icon": "icon-talk",
    "rounded": true,
    "attributes": {
      "roomName": "Test" 
      "roomToken": "abc123",
      "messageId": 42,
      "sentBy": "admin",
      "timestamp": "2021-12-17"
    }
  }
]

Describe alternatives you've considered
As said, the only other solution I see is parsing the url manually.

Additional context

@nickvergessen
Copy link
Member

nickvergessen commented Dec 17, 2021

Interesting, I was not aware of the attributes thing as it was not used in the core at the time of implementation:
https://github.com/nextcloud/server/blob/0447b53bda9fe95ea0cbed765aa332584605d652/lib/public/Search/SearchResultEntry.php#L115-L126

Code to adjust for Messages search is:

return new SearchResultEntry(
$iconUrl,
str_replace(
['{user}', '{conversation}'],
[$message->getActorDisplayName(), $room->getDisplayName($user->getUID())],
$subline
),
$messageStr,
$this->url->linkToRouteAbsolute('spreed.Page.showCall', ['token' => $room->getToken()]) . '#message_' . $comment->getId(),
'icon-talk', // $iconClass,
true
);

In order to not have too many unused attributes exposed which we can never remove/modify, let's only add:

{
    "conversation": "token",
    "messageId": 42
}

For now?

For conversation search we can of course only expose the conversation attribute:

$result[] = new SearchResultEntry(
$icon,
$room->getDisplayName($user->getUID()),
'',
$this->url->linkToRouteAbsolute('spreed.Page.showCall', ['token' => $room->getToken()]),
$iconClass,
true
);

@thisIsTheFoxe
Copy link
Author

@nickvergessen sounds great, thanks for the fast response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants