about summary refs log tree commit diff
path: root/MatrixUtils.RoomUpgradeCLI/Commands/DevCommands/DevDeleteRoomCommand.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-08-16 00:19:40 +0200
committerRory& <root@rory.gay>2025-08-16 00:19:40 +0200
commit97e5c8864c7efd79f97f1e527997d09cff635399 (patch)
tree562cdd066b2c74eafe7ddb398ac5a227c97872e3 /MatrixUtils.RoomUpgradeCLI/Commands/DevCommands/DevDeleteRoomCommand.cs
parentRoom upgrade CLI changes (diff)
downloadMatrixUtils-97e5c8864c7efd79f97f1e527997d09cff635399.tar.xz
Further room cleanup work
Diffstat (limited to 'MatrixUtils.RoomUpgradeCLI/Commands/DevCommands/DevDeleteRoomCommand.cs')
-rw-r--r--MatrixUtils.RoomUpgradeCLI/Commands/DevCommands/DevDeleteRoomCommand.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/MatrixUtils.RoomUpgradeCLI/Commands/DevCommands/DevDeleteRoomCommand.cs b/MatrixUtils.RoomUpgradeCLI/Commands/DevCommands/DevDeleteRoomCommand.cs
new file mode 100644

index 0000000..10d667f --- /dev/null +++ b/MatrixUtils.RoomUpgradeCLI/Commands/DevCommands/DevDeleteRoomCommand.cs
@@ -0,0 +1,33 @@ +using LibMatrix.Homeservers; + +namespace MatrixUtils.RoomUpgradeCLI.Commands; + +public class DevDeleteRoomCommand(ILogger<DevDeleteRoomCommand> logger, IHost host, RuntimeContext ctx, AuthenticatedHomeserverGeneric hs) : IHostedService { + public async Task StartAsync(CancellationToken cancellationToken) { + var synapse = hs as AuthenticatedHomeserverSynapse; + if (ctx.Args.Length == 2) { + var room = synapse.GetRoom(ctx.Args[1]); + await synapse.Admin.DeleteRoom(room.RoomId, new() { Purge = true }); + } + else { + string line; + do { + line = Console.ReadLine(); + if (string.IsNullOrWhiteSpace(line)) continue; + var room = synapse.GetRoom(line); + await synapse.Admin.DeleteRoom(room.RoomId, new() { Purge = true }); + } while (line is not null); + } + + 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