You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Add API for POST /user_directory/search (#457)
* Add API for POST /user_directory/search
This takes a JSON body of the form:
```json
{
"term": "search term",
"limit": 42,
}
```
where "term" is the term to match against user IDs, display names and domains and "limit" is the maximum number of results to return (which is defaulted server-side).
The response body looks like
```json
{
"results ": [
{ "user_id": "@someid:mydomain.com", "display_name": "Some Name", "avatar_url": "mx://..." },
...
],
"limited": false
}
```
where "limited" indicates whether the "limit" was used to truncate the list.
This commit is contained in:
@@ -678,6 +678,31 @@ MatrixBaseApis.prototype.setRoomDirectoryVisibilityAppService =
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// User Directory Operations
|
||||||
|
// =========================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the user directory with a term matching user IDs, display names and domains.
|
||||||
|
* @param {object} opts options
|
||||||
|
* @param {string} opts.term the term with which to search.
|
||||||
|
* @param {number} opts.limit the maximum number of results to return. The server will
|
||||||
|
* apply a limit if unspecified.
|
||||||
|
* @return {module:client.Promise} Resolves: an array of results.
|
||||||
|
*/
|
||||||
|
MatrixBaseApis.prototype.searchUserDirectory = function(opts) {
|
||||||
|
const body = {
|
||||||
|
search_term: opts.term,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (opts.limit !== undefined) {
|
||||||
|
body.limit = opts.limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._http.authedRequest(
|
||||||
|
undefined, "POST", "/user_directory/search", undefined, body,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Media operations
|
// Media operations
|
||||||
// ================
|
// ================
|
||||||
|
|||||||
Reference in New Issue
Block a user