1 files changed, 32 insertions, 0 deletions
diff --git a/MatrixUtils.RoomUpgradeCLI/Commands/DevCommands/DevDeleteAllRoomsCommand.cs b/MatrixUtils.RoomUpgradeCLI/Commands/DevCommands/DevDeleteAllRoomsCommand.cs
new file mode 100644
index 0000000..abae488
--- /dev/null
+++ b/MatrixUtils.RoomUpgradeCLI/Commands/DevCommands/DevDeleteAllRoomsCommand.cs
@@ -0,0 +1,32 @@
+using LibMatrix.Homeservers;
+
+namespace MatrixUtils.RoomUpgradeCLI.Commands;
+
+public class DevDeleteAllRoomsCommand(ILogger<DevDeleteAllRoomsCommand> logger, IHost host, RuntimeContext ctx, AuthenticatedHomeserverGeneric hs) : IHostedService {
+ public async Task StartAsync(CancellationToken cancellationToken) {
+ var synapse = hs as AuthenticatedHomeserverSynapse;
+ await foreach (var room in synapse.Admin.SearchRoomsAsync())
+ {
+ try
+ {
+ await synapse.Admin.DeleteRoom(room.RoomId, new() { ForcePurge = true });
+ Console.WriteLine($"Deleted room: {room.RoomId}");
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"Failed to delete room {room.RoomId}: {ex.Message}");
+ }
+ }
+
+ await host.StopAsync(cancellationToken);
+ }
+
+ public async Task StopAsync(CancellationToken cancellationToken) { }
+
+ private async Task PrintHelp() {
+ Console.WriteLine("Usage: execute [filename]");
+ Console.WriteLine("Options:");
+ Console.WriteLine(" --help Show this help message");
+ await host.StopAsync();
+ }
+}
\ No newline at end of file
|