about summary refs log tree commit diff
path: root/MatrixUtils.RoomUpgradeCLI/Commands/DevCommands
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-08-22 17:39:57 +0200
committerRory& <root@rory.gay>2025-08-22 17:39:57 +0200
commit93db033377b5e457bd04daf0b16f3d8b8cd77b44 (patch)
tree3a98c0c2704b505b8fc8dca960f2aaa43ef14f70 /MatrixUtils.RoomUpgradeCLI/Commands/DevCommands
parentFurther room cleanup work (diff)
downloadMatrixUtils-93db033377b5e457bd04daf0b16f3d8b8cd77b44.tar.xz
Room upgrade CLI changes, policy list work
Diffstat (limited to 'MatrixUtils.RoomUpgradeCLI/Commands/DevCommands')
-rw-r--r--MatrixUtils.RoomUpgradeCLI/Commands/DevCommands/DevDeleteAllRoomsCommand.cs32
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