3 files changed, 61 insertions, 1 deletions
diff --git a/MatrixUtils.Web/Pages/Tools/Debug/JoinRoom.razor b/MatrixUtils.Web/Pages/Tools/Debug/JoinRoom.razor
new file mode 100644
index 0000000..319c9e7
--- /dev/null
+++ b/MatrixUtils.Web/Pages/Tools/Debug/JoinRoom.razor
@@ -0,0 +1,59 @@
+@page "/Tools/Debug/JoinRoom"
+@using System.Collections.ObjectModel
+<h3>Join room</h3>
+<hr/>
+<span>Room ID: </span>
+<InputText @bind-Value="@RoomId"></InputText>
+<br/>
+<span>Via server: </span>
+<InputText @bind-Value="@Server"></InputText>
+<br/>
+<LinkButton OnClick="@Join">Join</LinkButton>
+<br/><br/>
+@foreach (var line in Log) {
+ <pre>@line</pre>
+ <br/>
+}
+
+@code {
+ AuthenticatedHomeserverGeneric? hs { get; set; }
+ ObservableCollection<string> Log { get; set; } = new ObservableCollection<string>();
+
+ [Parameter, SupplyParameterFromQuery(Name = "roomId")]
+ public string? RoomId { get; set; }
+
+ [Parameter, SupplyParameterFromQuery(Name = "via")]
+ public string? Server { get; set; }
+
+ protected override async Task OnInitializedAsync() {
+ hs = await sessionStore.GetCurrentHomeserver(navigateOnFailure: true);
+ if (hs is null) return;
+ Log.CollectionChanged += (sender, args) => StateHasChanged();
+
+ StateHasChanged();
+ Console.WriteLine("Rerendered!");
+ await base.OnInitializedAsync();
+ }
+
+ private async Task Join() {
+ if (string.IsNullOrWhiteSpace(RoomId)) return;
+ var room = hs.GetRoom(RoomId);
+ Log.Add("Got room object...");
+
+ if (hs is AuthenticatedHomeserverSynapse synapse) {
+ await synapse.Admin.BlockRoom(RoomId, false);
+ Log.Add($"Synapse: unblocked room");
+ }
+
+ try {
+ await room.JoinAsync([Server], checkIfAlreadyMember: false);
+ Log.Add("Joined room!");
+ }
+ catch (Exception e) {
+ Log.Add(e.ToString());
+ }
+
+ Log.Add("Done!");
+ }
+
+}
\ No newline at end of file
diff --git a/MatrixUtils.Web/Pages/Tools/Debug/LeaveRoom.razor b/MatrixUtils.Web/Pages/Tools/Debug/LeaveRoom.razor
index 9a56fc0..7844331 100644
--- a/MatrixUtils.Web/Pages/Tools/Debug/LeaveRoom.razor
+++ b/MatrixUtils.Web/Pages/Tools/Debug/LeaveRoom.razor
@@ -1,4 +1,4 @@
-@page "/Tools/LeaveRoom"
+@page "/Tools/Debug/LeaveRoom"
@using System.Collections.ObjectModel
<h3>Leave room</h3>
<hr/>
diff --git a/MatrixUtils.Web/Pages/Tools/Index.razor b/MatrixUtils.Web/Pages/Tools/Index.razor
index f99e932..4a44753 100644
--- a/MatrixUtils.Web/Pages/Tools/Index.razor
+++ b/MatrixUtils.Web/Pages/Tools/Index.razor
@@ -30,6 +30,7 @@
<h4 class="tool-category">Debugging tools</h4>
<hr/>
<a href="/Tools/Debug/SpaceDebug">Debug space relationships</a><br/>
+<a href="/Tools/Debug/JoinRoom">Join room by ID</a><br/>
<a href="/Tools/Debug/LeaveRoom">Leave room by ID</a><br/>
<a href="/Tools/Debug/MediaLocator">Locate lost media</a><br/>
<a href="/Tools/Debug/MigrateRoom">Migrate users from a split room to a new room</a><br/>
|