mirror of
https://github.com/UA-Fediland/synapse-admin.git
synced 2025-12-10 09:04:55 +00:00
Get avatar_url and displayname from v2/users API
API was added by synapse v1.13.0. Change-Id: I927b81882fa20e5b3de3d9fc216e2136f7036bba
This commit is contained in:
parent
8282a3caf8
commit
ab04db5baf
4 changed files with 149 additions and 122 deletions
|
|
@ -14,12 +14,24 @@ const jsonClient = (url, options = {}) => {
|
|||
return fetchUtils.fetchJson(url, options);
|
||||
};
|
||||
|
||||
const mxcUrlToHttp = mxcUrl => {
|
||||
const homeserver = localStorage.getItem("base_url");
|
||||
const re = /^mxc:\/\/([^/]+)\/(\w+)/;
|
||||
var ret = re.exec(mxcUrl);
|
||||
console.log("mxcClient " + ret);
|
||||
if (ret == null) return null;
|
||||
const serverName = ret[1];
|
||||
const mediaId = ret[2];
|
||||
return `${homeserver}/_matrix/media/r0/thumbnail/${serverName}/${mediaId}?width=24&height=24&method=scale`;
|
||||
};
|
||||
|
||||
const resourceMap = {
|
||||
users: {
|
||||
path: "/_synapse/admin/v2/users",
|
||||
map: u => ({
|
||||
...u,
|
||||
id: u.name,
|
||||
avatar_src: mxcUrlToHttp(u.avatar_url),
|
||||
is_guest: !!u.is_guest,
|
||||
admin: !!u.admin,
|
||||
deactivated: !!u.deactivated,
|
||||
|
|
@ -27,11 +39,7 @@ const resourceMap = {
|
|||
creation_ts_ms: u.creation_ts * 1000,
|
||||
}),
|
||||
data: "users",
|
||||
total: (json, from, perPage) => {
|
||||
return json.next_token
|
||||
? parseInt(json.next_token, 10) + perPage
|
||||
: from + json.users.length;
|
||||
},
|
||||
total: json => json.total,
|
||||
create: data => ({
|
||||
endpoint: `/_synapse/admin/v2/users/${data.id}`,
|
||||
body: data,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue