about summary refs log tree commit diff
path: root/ModerationClient/ViewModels/UserManagement/UserManagementViewModel.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-08-08 02:57:34 +0200
committerRory& <root@rory.gay>2024-08-08 03:02:10 +0200
commitdf5fe7c86e41235f99a9b0d69519a18581eddd5e (patch)
treed7ae3b2c9b98ffcf4fbe4613091dfc7db7e2c62b /ModerationClient/ViewModels/UserManagement/UserManagementViewModel.cs
parentList rooms (diff)
downloadModerationClient-df5fe7c86e41235f99a9b0d69519a18581eddd5e.tar.xz
Further work
Diffstat (limited to 'ModerationClient/ViewModels/UserManagement/UserManagementViewModel.cs')
-rw-r--r--ModerationClient/ViewModels/UserManagement/UserManagementViewModel.cs63
1 files changed, 63 insertions, 0 deletions
diff --git a/ModerationClient/ViewModels/UserManagement/UserManagementViewModel.cs b/ModerationClient/ViewModels/UserManagement/UserManagementViewModel.cs
new file mode 100644

index 0000000..7a2ad63 --- /dev/null +++ b/ModerationClient/ViewModels/UserManagement/UserManagementViewModel.cs
@@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text.Json; +using System.Threading.Tasks; +using ArcaneLibs.Collections; +using ArcaneLibs.Extensions; +using LibMatrix.EventTypes.Spec.State; +using LibMatrix.Helpers; +using LibMatrix.Homeservers; +using LibMatrix.Homeservers.ImplementationDetails.Synapse.Models.Responses; +using LibMatrix.Responses; +using MatrixUtils.Abstractions; +using Microsoft.Extensions.Logging; +using ModerationClient.Services; + +namespace ModerationClient.ViewModels; + +public partial class UserManagementViewModel : ViewModelBase { + public UserManagementViewModel(ILogger<UserManagementViewModel> logger, MatrixAuthenticationService authService, CommandLineConfiguration cfg) { + _logger = logger; + _authService = authService; + _cfg = cfg; + _ = Task.Run(Run).ContinueWith(x=>x.Exception?.Handle(y=> { + Console.WriteLine(y); + return true; + })); + } + + private readonly ILogger<UserManagementViewModel> _logger; + private readonly MatrixAuthenticationService _authService; + private readonly CommandLineConfiguration _cfg; + private string _status = "Loading..."; + public ObservableCollection<User> Users { get; set; } = []; + + public string Status { + get => _status + " " + DateTime.Now; + set => SetProperty(ref _status, value); + } + + public async Task Run() { + Users.Clear(); + Status = "Doing initial sync..."; + if (_authService.Homeserver is not AuthenticatedHomeserverSynapse synapse) { + Console.WriteLine("This client only supports Synapse homeservers."); + return; + } + + await foreach (var user in synapse.Admin.SearchUsersAsync(chunkLimit: 100)) { + Console.WriteLine("USERMANAGER GOT USER: " + user.ToJson(indent:false, ignoreNull: true)); + Users.Add(JsonSerializer.Deserialize<User>(user.ToJson())!); + } + Console.WriteLine("Done."); + } +} + +public class User : AdminUserListResult.AdminUserListResultUser { + +} \ No newline at end of file