@using LibMatrix.Homeservers.Extensions.NamedCaches
@using LibMatrix.Homeservers.ImplementationDetails.Synapse.Models.Requests
@if (string.IsNullOrWhiteSpace(Context.DeleteId)) {
Media options
Quarantine local media:
Quarantine remote media:
Delete remote media:
User options
Suspend local users:
Quarantine ALL local user media:
Delete ALL local user media:
Room deletion options
Block room:
Purge room:
Force purge room (unsafe):
Warning room User ID (optional):
@if (!string.IsNullOrWhiteSpace(Context.DeleteRequest.NewRoomUserId)) {
Warning room name:
Warning room message (plaintext):
}
Execute
}
@code {
[Parameter]
public required RoomShutdownContext Context { get; set; }
[Parameter]
public required AuthenticatedHomeserverSynapse Homeserver { get; set; }
private NamedCache TaskMap { get; set; } = null!;
protected override async Task OnInitializedAsync() {
TaskMap = new NamedCache(Homeserver, "gay.rory.matrixutils.synapse_room_shutdown_tasks");
}
public class RoomShutdownContext {
public required string RoomId { get; set; }
public string? DeleteId { get; set; }
public ExtraDeleteOptions ExtraOptions { get; set; } = new();
public SynapseAdminRoomDeleteRequest DeleteRequest { get; set; } = new() {
Block = true,
Purge = true,
ForcePurge = false
};
public class ExtraDeleteOptions {
// room options
public bool QuarantineLocalMedia { get; set; }
public bool QuarantineRemoteMedia { get; set; }
public bool DeleteRemoteMedia { get; set; }
// user options
public bool SuspendLocalUsers { get; set; }
public bool QuarantineLocalUserMedia { get; set; }
public bool DeleteLocalUserMedia { get; set; }
}
}
public async Task OnComplete() {
await OnCompleteLock.WaitAsync();
try {
await TaskMap.RemoveValueAsync(Context.DeleteId!);
}
finally {
OnCompleteLock.Release();
}
}
public async Task DeleteRoom() {
await TaskMap.SetValueAsync(Context.RoomId, Context);
}
private static readonly SemaphoreSlim OnCompleteLock = new(1, 1);
}