From 03313562d21d5db9bf6a14ebbeab80e06c883d3a Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 24 Jan 2024 02:31:56 +0100 Subject: MRU->RMU, fixes, cleanup --- MatrixUtils.Web/Pages/HSAdmin/RoomQuery.razor | 200 ++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 MatrixUtils.Web/Pages/HSAdmin/RoomQuery.razor (limited to 'MatrixUtils.Web/Pages/HSAdmin/RoomQuery.razor') diff --git a/MatrixUtils.Web/Pages/HSAdmin/RoomQuery.razor b/MatrixUtils.Web/Pages/HSAdmin/RoomQuery.razor new file mode 100644 index 0000000..10628ad --- /dev/null +++ b/MatrixUtils.Web/Pages/HSAdmin/RoomQuery.razor @@ -0,0 +1,200 @@ +@page "/HSAdmin/RoomQuery" +@using LibMatrix.Responses.Admin +@using LibMatrix.Filters +@using LibMatrix.Homeservers +@using ArcaneLibs.Extensions + +

Homeserver Administration - Room Query

+ + +
+ +
+ +
+
+ + Local filtering (slow) + + +
+ String contains + Room ID: + Room name: + Canonical alias: + Creator: + Room version: + Encryption algorithm: + Join rules: + Guest access: + History visibility: + + Optional checks + + Is federated: + @if (Filter.CheckFederation) { + + } + + + Is public: + @if (Filter.CheckPublic) { + + } + + + Ranges + + state events + + + members + + + local members + +
+
+ +
+ +@if (Results.Count > 0) { +

Found @Results.Count rooms

+
+ TSV data (copy/paste) +
+            
+                @foreach (var res in Results) {
+                    
+                        
+                        
+                        
+                        
+                    
+                }
+            
@res.RoomId@("\t")@res.CanonicalAlias@("\t")@res.Creator@("\t")@res.Name
+
+
+} + +@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 +
+ Full result data +
@res.ToJson(ignoreNull: true)
+
+
+} + + + +@code { + + [Parameter] + [SupplyParameterFromQuery(Name = "order_by")] + public string? OrderBy { get; set; } + + [Parameter] + [SupplyParameterFromQuery(Name = "name_search")] + public string SearchTerm { get; set; } + + [Parameter] + [SupplyParameterFromQuery(Name = "ascending")] + public bool Ascending { get; set; } + + public List Results { get; set; } = new(); + + private string Status { get; set; } + + public LocalRoomQueryFilter Filter { get; set; } = new(); + + protected override Task OnParametersSetAsync() { + if (Ascending == null) + Ascending = true; + OrderBy ??= "name"; + return Task.CompletedTask; + } + + private async Task Search() { + Results.Clear(); + var hs = await RMUStorage.GetCurrentSessionOrNavigate(); + if (hs is AuthenticatedHomeserverSynapse synapse) { + var searchRooms = synapse.Admin.SearchRoomsAsync(orderBy: OrderBy!, dir: Ascending ? "f" : "b", searchTerm: SearchTerm, localFilter: Filter).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" } + }; + +} -- cgit 1.4.1