Class DirectoryService
Room aliases, the public room directory and user search.
Inherited Members
Namespace: Uniform.Matrix.Server.Rooms
Assembly: Uniform.Matrix.Server.dll
Syntax
public sealed class DirectoryService
Constructors
| Edit this page View SourceDirectoryService(IDbContextFactory<ServerDbContext>, RoomService, IOptions<ServerOptions>, RemoteJoins, FederationClient)
Create the service.
Declaration
public DirectoryService(IDbContextFactory<ServerDbContext> contexts, RoomService rooms, IOptions<ServerOptions> options, RemoteJoins remoteJoins, FederationClient federation)
Parameters
| Type | Name | Description |
|---|---|---|
| IDbContextFactory<ServerDbContext> | contexts | |
| RoomService | rooms | |
| IOptions<ServerOptions> | options | |
| RemoteJoins | remoteJoins | |
| FederationClient | federation |
Methods
| Edit this page View SourceCreateAliasAsync(string, string, string, CancellationToken)
Create a local alias for a room the user is joined to; throw 409 when the alias exists.
Declaration
public Task CreateAliasAsync(string userId, string alias, string roomId, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | alias | |
| string | roomId | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
DeleteAliasAsync(string, string, CancellationToken)
Delete a local alias: its creator, a server admin, or a room member allowed to change the canonical alias may.
Declaration
public Task DeleteAliasAsync(string userId, string alias, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | alias | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
GetAliasAsync(string, CancellationToken)
Return the room of an alias and servers in it; aliases of other servers are asked from them. Throw M_NOT_FOUND for unknown aliases.
Declaration
public Task<JsonObject> GetAliasAsync(string alias, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | alias | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
GetFederationHierarchyAsync(string, string, bool, CancellationToken)
Return a local space and its direct children for another server, as federation hierarchy answers; rooms the server may not see are listed as inaccessible.
Declaration
public Task<JsonObject> GetFederationHierarchyAsync(string origin, string roomId, bool suggestedOnly, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | origin | |
| string | roomId | |
| bool | suggestedOnly | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
GetHierarchyAsync(string, string, int?, int, string?, bool, CancellationToken, IReadOnlyCollection<string>?)
Return the hierarchy of a space: the space and the local rooms its m.space.child events name, depth first, that the user may see. A space not here is asked from a server in it, such as a via server the client gives, with its direct children.
Declaration
public Task<JsonObject> GetHierarchyAsync(string userId, string roomId, int? maxDepth, int limit, string? from, bool suggestedOnly, CancellationToken cancellationToken, IReadOnlyCollection<string>? via = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | Who asks. |
| string | roomId | The space. |
| int? | maxDepth | Deepest level, the space being 0; unlimited when null. |
| int | limit | Most rooms per page. |
| string | from | Token of the page, |
| bool | suggestedOnly | Only children marked |
| CancellationToken | cancellationToken | Cancellation token. |
| IReadOnlyCollection<string> | via | Servers to ask about a space not here, besides its room ID's server. |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
GetLocalAliasAsync(string, CancellationToken)
Return the room of a local alias and the servers with members joined to it, this one first, as query/directory answers other servers; throw M_NOT_FOUND for unknown aliases.
Declaration
public Task<(string RoomId, IReadOnlyList<string> Servers)> GetLocalAliasAsync(string alias, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | alias | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<(string RoomId, IReadOnlyList<string> Servers)> |
GetPublicRoomsAsync(int?, string?, string?, string?, CancellationToken)
Return a page of the public room directory, most members first.
Declaration
public Task<JsonObject> GetPublicRoomsAsync(int? limit, string? since, string? searchTerm, string? server, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| int? | limit | Rooms per page; all when null. |
| string | since | Token of the page, |
| string | searchTerm | Text to find in the name, topic or canonical alias. |
| string | server | Server whose directory to list; other servers need federation. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
GetRoomAliasesAsync(string, string, CancellationToken)
Return the local aliases of a room the user is joined to.
Declaration
public Task<JsonObject> GetRoomAliasesAsync(string userId, string roomId, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | roomId | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
GetSummaryAsync(string?, string, CancellationToken, IReadOnlyCollection<string>?)
Return the summary of a room, as the room directory shows it with the user's membership, version and encryption; rooms not here are asked from servers in them. Throw M_NOT_FOUND when the user may not see it.
Declaration
public Task<JsonObject> GetSummaryAsync(string? userId, string roomIdOrAlias, CancellationToken cancellationToken, IReadOnlyCollection<string>? via = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | Who asks, or null without a login. |
| string | roomIdOrAlias | Room ID or alias. |
| CancellationToken | cancellationToken | Cancellation token. |
| IReadOnlyCollection<string> | via | Servers to ask about a room not here, besides the alias's and the room ID's server. |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
GetVisibilityAsync(string, CancellationToken)
Return whether a room is listed in the directory: public or private.
Declaration
public Task<JsonObject> GetVisibilityAsync(string roomId, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | roomId | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
SearchUsersAsync(string, string, int, CancellationToken)
Search users who share a room with the requester or are in a public room, by user ID or display name.
Declaration
public Task<JsonObject> SearchUsersAsync(string userId, string term, int limit, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | term | |
| int | limit | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
SetVisibilityAsync(string, string, string, CancellationToken, bool)
List or unlists a room; a server admin, or a member allowed to change the canonical alias, may.
Declaration
public Task SetVisibilityAsync(string userId, string roomId, string visibility, CancellationToken cancellationToken, bool serverAdmin = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | roomId | |
| string | visibility | |
| CancellationToken | cancellationToken | |
| bool | serverAdmin |
Returns
| Type | Description |
|---|---|
| Task |