Add docs for the /mentions endpoint

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2018-04-26 10:14:00 +02:00 коммит произвёл Daniel Calviño Sánchez
Родитель 4cf756fbe6
Коммит 982bf986ba
5 изменённых файлов: 31 добавлений и 8 удалений

Просмотреть файл

@ -130,8 +130,8 @@ return [
],
],
[
'name' => 'Chat#autoComplete',
'url' => '/api/{apiVersion}/chat/{token}/autocomplete',
'name' => 'Chat#mentions',
'url' => '/api/{apiVersion}/chat/{token}/mentions',
'verb' => 'GET',
'requirements' => [
'apiVersion' => 'v1',

Просмотреть файл

@ -490,6 +490,31 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`
+ `201 Created`
+ `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
### Set display name

Просмотреть файл

@ -145,7 +145,7 @@
this._autoCompleteRequestCall.abort();
}
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: {
search: query
},

Просмотреть файл

@ -58,11 +58,9 @@ class SearchPlugin implements ISearchPlugin {
* @since 13.0.0
*/
public function search($search, $limit, $offset, ISearchResult $searchResult) {
$participants = $this->room->getParticipants();
$this->searchUsers($search, array_map('strval', array_keys($participants['users'])), $searchResult);
// FIXME Handle guests
return false;

Просмотреть файл

@ -308,7 +308,7 @@ class ChatController extends OCSController {
* @param int $limit
* @return DataResponse
*/
public function autoComplete($token, $search, $limit = 20) {
public function mentions($token, $search, $limit = 20) {
$room = $this->getRoom($token);
if ($room === null) {
return new DataResponse([], Http::STATUS_NOT_FOUND);