зеркало из https://github.com/nextcloud/spreed.git
Add docs for the /mentions endpoint
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Родитель
4cf756fbe6
Коммит
982bf986ba
|
@ -130,8 +130,8 @@ return [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'Chat#autoComplete',
|
'name' => 'Chat#mentions',
|
||||||
'url' => '/api/{apiVersion}/chat/{token}/autocomplete',
|
'url' => '/api/{apiVersion}/chat/{token}/mentions',
|
||||||
'verb' => 'GET',
|
'verb' => 'GET',
|
||||||
'requirements' => [
|
'requirements' => [
|
||||||
'apiVersion' => 'v1',
|
'apiVersion' => 'v1',
|
||||||
|
|
|
@ -489,6 +489,31 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`
|
||||||
- Header:
|
- Header:
|
||||||
+ `201 Created`
|
+ `201 Created`
|
||||||
+ `404 Not Found` When the room could not be found for the participant
|
+ `404 Not Found` When the room could not be found for the participant
|
||||||
|
|
||||||
|
### Get mention autocomplete suggestions
|
||||||
|
|
||||||
|
* Method: `GET`
|
||||||
|
* Endpoint: `/chat/{token}/mentions`
|
||||||
|
* Data:
|
||||||
|
|
||||||
|
field | type | Description
|
||||||
|
------|------|------------
|
||||||
|
`search` | string | Search term for name suggestions (should at least be 1 character)
|
||||||
|
`limit` | int | Number of suggestions to receive (20 by default)
|
||||||
|
|
||||||
|
* Response:
|
||||||
|
- Status code:
|
||||||
|
+ `200 OK`
|
||||||
|
+ `404 Not Found` When the room could not be found for the participant
|
||||||
|
|
||||||
|
- Data:
|
||||||
|
Array of suggestions, each suggestion has at least:
|
||||||
|
|
||||||
|
field | type | Description
|
||||||
|
------|------|------------
|
||||||
|
`id` | string | The user id which should be sent as `@<id>` in the message
|
||||||
|
`label` | string | The displayname of the user
|
||||||
|
`source` | string | The type of the user, currently only `user`
|
||||||
|
|
||||||
## Guests
|
## Guests
|
||||||
|
|
||||||
|
|
|
@ -119,8 +119,8 @@
|
||||||
},
|
},
|
||||||
displayTpl: '<li>'
|
displayTpl: '<li>'
|
||||||
+ '<span class="avatar-name-wrapper">'
|
+ '<span class="avatar-name-wrapper">'
|
||||||
+ '<div class="avatar" '
|
+ '<div class="avatar"'
|
||||||
+ 'data-username="${id}"' // for avatars
|
+ ' data-username="${id}"' // for avatars
|
||||||
+ ' data-user="${id}"' // for contactsmenu
|
+ ' data-user="${id}"' // for contactsmenu
|
||||||
+ ' data-user-display-name="${label}"></div>'
|
+ ' data-user-display-name="${label}"></div>'
|
||||||
+ ' <strong>${label}</strong>'
|
+ ' <strong>${label}</strong>'
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
this._autoCompleteRequestCall.abort();
|
this._autoCompleteRequestCall.abort();
|
||||||
}
|
}
|
||||||
this._autoCompleteRequestCall = $.ajax({
|
this._autoCompleteRequestCall = $.ajax({
|
||||||
url: OC.linkToOCS('apps/spreed/api/v1/chat', 2) + self.collection.token + '/autocomplete',
|
url: OC.linkToOCS('apps/spreed/api/v1/chat', 2) + self.collection.token + '/mentions',
|
||||||
data: {
|
data: {
|
||||||
search: query
|
search: query
|
||||||
},
|
},
|
||||||
|
|
|
@ -58,11 +58,9 @@ class SearchPlugin implements ISearchPlugin {
|
||||||
* @since 13.0.0
|
* @since 13.0.0
|
||||||
*/
|
*/
|
||||||
public function search($search, $limit, $offset, ISearchResult $searchResult) {
|
public function search($search, $limit, $offset, ISearchResult $searchResult) {
|
||||||
|
|
||||||
$participants = $this->room->getParticipants();
|
$participants = $this->room->getParticipants();
|
||||||
|
|
||||||
$this->searchUsers($search, array_map('strval', array_keys($participants['users'])), $searchResult);
|
$this->searchUsers($search, array_map('strval', array_keys($participants['users'])), $searchResult);
|
||||||
|
|
||||||
// FIXME Handle guests
|
// FIXME Handle guests
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -308,7 +308,7 @@ class ChatController extends OCSController {
|
||||||
* @param int $limit
|
* @param int $limit
|
||||||
* @return DataResponse
|
* @return DataResponse
|
||||||
*/
|
*/
|
||||||
public function autoComplete($token, $search, $limit = 20) {
|
public function mentions($token, $search, $limit = 20) {
|
||||||
$room = $this->getRoom($token);
|
$room = $this->getRoom($token);
|
||||||
if ($room === null) {
|
if ($room === null) {
|
||||||
return new DataResponse([], Http::STATUS_NOT_FOUND);
|
return new DataResponse([], Http::STATUS_NOT_FOUND);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче