@page "/DevTools"
@using LibMatrix.Homeservers
@using LibMatrix.EventTypes.Spec.State
DevTools
Mass create projects
Destroy all projects
@code {
private BugMineClient? Client { get; set; }
protected override async Task OnInitializedAsync() {
Client = await BugMineStorage.GetCurrentSessionOrNavigate();
}
private async Task DestroyAllProjects() {
var ss = new SemaphoreSlim(4, 4);
await foreach (var proj in Client.Homeserver.GetJoinedRoomsByType(BugMineProject.RoomType)) {
// Task.Run(async () => {
// await ss.WaitAsync();
await proj.SendStateEventAsync(RoomNameEventContent.EventId, new RoomNameEventContent() {
Name = "Disbanded BugMine project."
});
await proj.SendStateEventAsync(RoomJoinRulesEventContent.EventId, new RoomJoinRulesEventContent() {
JoinRule = RoomJoinRulesEventContent.JoinRules.Private
});
await proj.SendStateEventAsync(RoomCanonicalAliasEventContent.EventId, new RoomCanonicalAliasEventContent() {
Alias = null
});
await proj.LeaveAsync("Disbanded room.");
// ss.Release();
// });
}
}
private async Task MassCreateProjects() {
// var rooms = await Client.Homeserver.GetJoinedRooms();
// List roomNames = (await Task.WhenAll(rooms.Select(x => x.GetNameAsync()))).Where(x => x != null).ToList();
for (int i = 0; i < 20; i++) {
Task.Run(async () => {
// var randomName = roomNames[Random.Shared.Next(roomNames.Count)];
var proj = await Client.CreateProject(new() {
Name = /*randomName + */Guid.NewGuid().ToString()[..8]
});
await proj.CreateIssue(new() {
Name = "meow"
});
});
}
}
}