blob: d5daf754a148d586dc5b75de0f62fccef2c60203 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
@using LibMatrix.Homeservers.Extensions.NamedCaches
@using LibMatrix.Homeservers.ImplementationDetails.Synapse.Models.Requests
@if (string.IsNullOrWhiteSpace(Context.DeleteId)) {
<b>Media options</b>
<br/>
<hr/>
<span>Quarantine local media: </span>
<InputCheckbox @bind-Value="@Context.ExtraOptions.QuarantineLocalMedia"/>
<br/>
<span>Quarantine remote media: </span>
<InputCheckbox @bind-Value="@Context.ExtraOptions.QuarantineRemoteMedia"/>
<br/>
<span>Delete remote media: </span>
<InputCheckbox @bind-Value="@Context.ExtraOptions.DeleteRemoteMedia"/>
<br/>
<b>User options</b>
<br/>
<hr/>
<span>Suspend local users: </span>
<InputCheckbox @bind-Value="@Context.ExtraOptions.SuspendLocalUsers"></InputCheckbox>
<br/>
<span>Quarantine <b>ALL</b> local user media: </span>
<InputCheckbox @bind-Value="@Context.ExtraOptions.QuarantineLocalUserMedia"></InputCheckbox>
<br/>
<span>Delete <b>ALL</b> local user media: </span>
<InputCheckbox @bind-Value="@Context.ExtraOptions.DeleteLocalUserMedia"></InputCheckbox>
<br/>
<b>Room deletion options</b>
<br/>
<hr/>
<span>Block room: </span>
<InputCheckbox @bind-Value="@Context.DeleteRequest.Block"/>
<br/>
<span>Purge room: </span>
<InputCheckbox @bind-Value="@Context.DeleteRequest.Purge"/>
<br/>
<span>Force purge room (unsafe): </span>
<InputCheckbox @bind-Value="@Context.DeleteRequest.ForcePurge"></InputCheckbox>
<br/>
<span>Warning room User ID (optional): </span>
<FancyTextBox @bind-Value="@Context.DeleteRequest.NewRoomUserId"/>
<br/>
@if (!string.IsNullOrWhiteSpace(Context.DeleteRequest.NewRoomUserId)) {
<span>Warning room name: </span>
<FancyTextBox @bind-Value="@Context.DeleteRequest.RoomName"/>
<br/>
<span>Warning room message (plaintext): </span>
<FancyTextBox Multiline="true" @bind-Value="@Context.DeleteRequest.Message"/>
<br/>
}
<LinkButton OnClick="@DeleteRoom">Execute</LinkButton>
}
@code {
[Parameter]
public required RoomShutdownContext Context { get; set; }
[Parameter]
public required AuthenticatedHomeserverSynapse Homeserver { get; set; }
private NamedCache<RoomShutdownContext> TaskMap { get; set; } = null!;
protected override async Task OnInitializedAsync() {
TaskMap = new NamedCache<RoomShutdownContext>(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);
}
|