@page "/HSAdmin/RoomQuery" @using MatrixRoomUtils.Core.Extensions @using MatrixRoomUtils.Core.Responses.Admin

Homeserver Administration - Room Query






@if (Results.Count > 0) {

Found @Results.Count rooms

} @foreach (var res in Results) {

@if (!string.IsNullOrWhiteSpace(res.CanonicalAlias)) { @res.CanonicalAlias (@res.RoomId)
} else { @res.RoomId
} @if (!string.IsNullOrWhiteSpace(res.Creator)) { Created by
}

@res.StateEvents state events
@res.JoinedMembers members, of which @res.JoinedLocalMembers are on this server
} @code { [Parameter] [SupplyParameterFromQuery(Name = "order_by")] public string? OrderBy { get; set; } [Parameter] [SupplyParameterFromQuery(Name = "name_search")] public string SearchTerm { get; set; } [Parameter] [SupplyParameterFromQuery(Name = "content_search")] public string ContentSearchTerm { get; set; } [Parameter] [SupplyParameterFromQuery(Name = "ascending")] public bool Ascending { get; set; } public List Results { get; set; } = new(); private string Status { get; set; } protected override async Task OnParametersSetAsync() { if (Ascending == null) Ascending = true; OrderBy ??= "name"; } private async Task Search() { Results.Clear(); var searchRooms = RuntimeCache.CurrentHomeServer.Admin.SearchRoomsAsync(orderBy: OrderBy!, dir: Ascending ? "f" : "b", searchTerm: SearchTerm, contentSearch: ContentSearchTerm).GetAsyncEnumerator(); while (await searchRooms.MoveNextAsync()) { var room = searchRooms.Current; Console.WriteLine("Hit: " + room.ToJson(false)); Results.Add(room); if (Results.Count % 10 == 0) StateHasChanged(); } } private readonly Dictionary validOrderBy = new() { { "name", "Room name" }, { "canonical_alias", "Main alias address" }, { "joined_members", "Number of members (reversed)" }, { "joined_local_members", "Number of local members (reversed)" }, { "version", "Room version" }, { "creator", "Creator of the room" }, { "encryption", "End-to-end encryption algorithm" }, { "federatable", "Is room federated" }, { "public", "Visibility in room list" }, { "join_rules", "Join rules" }, { "guest_access", "Guest access" }, { "history_visibility", "Visibility of history" }, { "state_events", "Number of state events" } }; }