Classes
Methods
# async createRegistrationToken(options)
Create a new registration token.
Parameters:
Name | Type | Description |
---|---|---|
options |
Options to pass to the request. |
The newly created token.
# async deleteRegistrationToken(token)
Delete a registration token
Parameters:
Name | Type | Description |
---|---|---|
token |
The token to update. |
A promise that resolves upon success.
# async deleteRoom(roomId) → {Promise}
Deletes a room from the server, purging all record of it.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string
|
The room to delete. |
Resolves when complete.
Promise
# async getDeleteRoomState(roomId) → {Promise.<Array.<any>>}
Gets the status of all active deletion tasks, and all those completed in the last 24h, for the given room_id.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string
|
The room ID to get deletion state for. |
Resolves to the room's deletion status results.
Promise.<Array.<any>>
# async getRegistrationToken(token)
Get details about a single token.
Parameters:
Name | Type | Description |
---|---|---|
token |
The token to fetch. |
A registration tokens, or null if not found.
# async getRoomState(roomId) → {Promise.<Array.<any>>}
Gets a list of state events in a room.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string
|
The room ID to get state for. |
Resolves to the room's state events.
Promise.<Array.<any>>
# async getUser(userId) → {Promise.<SynapseUser>}
Get information about a user. The client making the request must be an admin user.
Parameters:
Name | Type | Description |
---|---|---|
userId |
string
|
The user ID to check. |
The resulting Synapse user record
Promise.<SynapseUser>
# async isAdmin(userId) → {Promise.<boolean>}
Determines if the given user is a Synapse server administrator for this homeserver. The
client making the request must be an admin user themselves (check with `isSelfAdmin`)
Parameters:
Name | Type | Description |
---|---|---|
userId |
string
|
The user ID to check. |
Resolves to true if the user is an admin, false otherwise.
Throws if there's an error.
Promise.<boolean>
# async isSelfAdmin() → {Promise.<boolean>}
Determines if the current user is an admin for the Synapse homeserver.
Resolve to true if the user is an admin, false otherwise.
Throws if there's an error.
Promise.<boolean>
# async listAllUsers(options) → {AsyncGenerator.<SynapseUserListing>}
Get a list of all users registered with Synapse, optionally filtered by some criteria. The
client making the request must be an admin user.
This method returns an async generator that can be used to filter results.
Parameters:
Name | Type | Description |
---|---|---|
options |
Options to pass to the user listing function |
AsyncGenerator.<SynapseUserListing>
Example
for await (const user of synapseAdminApis.listAllUsers()) {
if (user.name === '@alice:example.com') {
return user;
}
}
# async listRegistrationTokens(valid)
List all registration tokens on the homeserver.
Parameters:
Name | Type | Description |
---|---|---|
valid |
If true, only valid tokens are returned. If false, only tokens that have expired or have had all uses exhausted are returned. If omitted, all tokens are returned regardless of validity. |
An array of registration tokens.
# async listRooms(searchTerm, from, limit, orderBy, reverseOrder) → {Promise.<SynapseRoomList>}
Lists the rooms on the server.
Parameters:
Name | Type | Description |
---|---|---|
searchTerm |
string
|
A term to search for in the room names |
from |
string
|
A previous batch token to search from |
limit |
number
|
The maximum number of rooms to return |
orderBy |
SynapseRoomProperty
|
A property of rooms to order by |
reverseOrder |
boolean
|
True to reverse the orderBy direction. |
Resolves to the server's rooms, ordered and filtered.
Promise.<SynapseRoomList>
# async listUsers(from, limit, name, guests, deactivated) → {Promise.<SynapseUserList>}
Get a list of users registered with Synapse, optionally filtered by some criteria. The
client making the request must be an admin user.
Parameters:
Name | Type | Description |
---|---|---|
from |
string
|
The token to continue listing users from. |
limit |
number
|
The maximum number of users to request. |
name |
string
|
Optional localpart or display name filter for results. |
guests |
boolean
|
Whether or not to include guest accounts. Default true. |
deactivated |
boolean
|
Whether or not to include deactivated accounts. Default false. |
A batch of user results.
Promise.<SynapseUserList>
# async makeRoomAdmin(roomId, userId)
Grants another user the highest power available to a local user who is in the room.
If the user is not in the room, and it is not publicly joinable, then invite the user.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
The room to make the user admin in. | |
userId |
The user to make admin in the room. If undefined, it uses the authenticated user. |
Resolves when complete.
# async updateRegistrationToken(token, options)
Update an existing registration token.
Parameters:
Name | Type | Description |
---|---|---|
token |
The token to update. | |
options |
Options to pass to the request. |
The newly created token.
# async upsertUser(userId, opts) → {Promise.<SynapseUser>}
Create or update a given user on a Synapse server. The
client making the request must be an admin user.
Parameters:
Name | Type | Description |
---|---|---|
userId |
string
|
The user ID to check. |
opts |
SynapseUserProperties
|
Options to set when creating or updating the user. |
The resulting Synapse user record
Promise.<SynapseUser>