From 93db033377b5e457bd04daf0b16f3d8b8cd77b44 Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 22 Aug 2025 17:39:57 +0200 Subject: Room upgrade CLI changes, policy list work --- .../DevCommands/DevDeleteAllRoomsCommand.cs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 MatrixUtils.RoomUpgradeCLI/Commands/DevCommands/DevDeleteAllRoomsCommand.cs (limited to 'MatrixUtils.RoomUpgradeCLI/Commands/DevCommands') 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 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 -- cgit 1.5.1