about summary refs log tree commit diff
path: root/MatrixUtils.RoomUpgradeCLI/Commands/NewFileCommand.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixUtils.RoomUpgradeCLI/Commands/NewFileCommand.cs')
-rw-r--r--MatrixUtils.RoomUpgradeCLI/Commands/NewFileCommand.cs13
1 files changed, 13 insertions, 0 deletions
diff --git a/MatrixUtils.RoomUpgradeCLI/Commands/NewFileCommand.cs b/MatrixUtils.RoomUpgradeCLI/Commands/NewFileCommand.cs

index 0959857..08daf71 100644 --- a/MatrixUtils.RoomUpgradeCLI/Commands/NewFileCommand.cs +++ b/MatrixUtils.RoomUpgradeCLI/Commands/NewFileCommand.cs
@@ -19,6 +19,19 @@ public class NewFileCommand(ILogger<NewFileCommand> logger, IHost host, RuntimeC await PrintHelp(); } await rb.ApplyRoomUpgradeCLIArgs(hs, ctx.Args[2..], isNewState: true); + // check for room membership! + if (rb is RoomUpgradeBuilder rub) { + try { + var room = hs.GetRoom(rub.OldRoomId); + var membership = await room.GetStateAsync<RoomMemberEventContent>(RoomMemberEventContent.EventId, hs.UserId); + } + catch (Exception e) { + Console.WriteLine("Error checking room membership: " + e.Message); + Console.WriteLine("Please ensure you are a member of the room you are trying to upgrade. -- ABORTING --"); + await host.StopAsync(); + return; + } + } await File.WriteAllTextAsync(filename, rb.ToJson(), cancellationToken); await host.StopAsync(cancellationToken);