From 6769b0fd6f37cbc27646fa0ca8e458489c935039 Mon Sep 17 00:00:00 2001 From: Rory& Date: Tue, 9 Dec 2025 23:42:07 +0100 Subject: Commit various changes that never made it into git --- .../Pages/HSAdmin/Synapse/BlockMedia.razor | 4 +- .../SynapseRoomShutdownWindowContent.razor | 2 +- .../Synapse/SubTools/SynapseRoomStateResync.razor | 3 +- .../Client/ClientComponents/ClientSyncWrapper.cs | 10 +- MatrixUtils.Web/Pages/Rooms/Create.razor | 39 +++-- MatrixUtils.Web/Pages/Rooms/PolicyList.razor | 56 +++---- MatrixUtils.Web/Pages/Rooms/PolicyList.razor.cs | 8 +- MatrixUtils.Web/Pages/Rooms/PolicyList2.razor | 42 +++-- .../PolicyListEditorHeader.razor | 4 +- .../PolicyListRowComponent.razor | 12 +- MatrixUtils.Web/Pages/Rooms/PolicyLists.razor | 2 +- .../RoomCreateInitialStateOptions.razor | 8 +- MatrixUtils.Web/Pages/Rooms/Space.razor | 81 ++++----- MatrixUtils.Web/Pages/Rooms/StateEditor.razor | 16 +- MatrixUtils.Web/Pages/Rooms/StateViewer.razor | 53 +++--- MatrixUtils.Web/Pages/Rooms/Timeline.razor | 10 +- MatrixUtils.Web/Pages/StreamTest.razor | 6 +- .../Pages/Tools/Info/PolicyListActivity.razor | 8 +- .../Pages/Tools/Info/SessionCount.razor | 4 +- .../Pages/Tools/Moderation/FindUsersByRegex.razor | 2 +- .../Pages/Tools/Moderation/MembershipHistory.razor | 181 +++++++++++++-------- .../Pages/Tools/Moderation/RoomIntersections.razor | 8 +- .../Pages/Tools/Moderation/UserTrace.razor | 4 +- 23 files changed, 317 insertions(+), 246 deletions(-) (limited to 'MatrixUtils.Web/Pages') diff --git a/MatrixUtils.Web/Pages/HSAdmin/Synapse/BlockMedia.razor b/MatrixUtils.Web/Pages/HSAdmin/Synapse/BlockMedia.razor index e9d0cd2..5ccaca9 100644 --- a/MatrixUtils.Web/Pages/HSAdmin/Synapse/BlockMedia.razor +++ b/MatrixUtils.Web/Pages/HSAdmin/Synapse/BlockMedia.razor @@ -96,7 +96,7 @@ } } - private StateEventResponse? Event { get; set; } + private MatrixEventResponse? Event { get; set; } private string? EventJson { get; @@ -140,7 +140,7 @@ private async Task ExpandEventJson() { Console.WriteLine("Expanding event JSON..."); if (!string.IsNullOrWhiteSpace(EventJson)) { - Event = JsonSerializer.Deserialize(EventJson); + Event = JsonSerializer.Deserialize(EventJson); MxcUrl = Event?.ContentAs()?.Url; Console.WriteLine($"MXC URL: {MxcUrl}"); diff --git a/MatrixUtils.Web/Pages/HSAdmin/Synapse/Components/SynapseRoomShutdownWindowContent.razor b/MatrixUtils.Web/Pages/HSAdmin/Synapse/Components/SynapseRoomShutdownWindowContent.razor index fc9f8e8..b0e6a89 100644 --- a/MatrixUtils.Web/Pages/HSAdmin/Synapse/Components/SynapseRoomShutdownWindowContent.razor +++ b/MatrixUtils.Web/Pages/HSAdmin/Synapse/Components/SynapseRoomShutdownWindowContent.razor @@ -233,7 +233,7 @@ else { } } - private async Task TryGetTombstoneAsync() { + private async Task TryGetTombstoneAsync() { if (EditorOnly) return null; try { return (await Homeserver.Admin.GetRoomStateAsync(Context.RoomId, RoomTombstoneEventContent.EventId)).Events.FirstOrDefault(x => x.StateKey == ""); diff --git a/MatrixUtils.Web/Pages/HSAdmin/Synapse/SubTools/SynapseRoomStateResync.razor b/MatrixUtils.Web/Pages/HSAdmin/Synapse/SubTools/SynapseRoomStateResync.razor index c2446a2..3cc5a6a 100644 --- a/MatrixUtils.Web/Pages/HSAdmin/Synapse/SubTools/SynapseRoomStateResync.razor +++ b/MatrixUtils.Web/Pages/HSAdmin/Synapse/SubTools/SynapseRoomStateResync.razor @@ -39,7 +39,6 @@ } @* stage 3 *@ - @if (Stage == 3) {

Rejoining room, please wait...

Members left to restore:

@@ -82,7 +81,7 @@ private Exception? Error { get; set; } // Stage 1 - private List? Members { get; set; } + private List? Members { get; set; } // Stage 2 private SynapseAdminRoomDeleteStatus? DeleteStatus { get; set; } diff --git a/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientSyncWrapper.cs b/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientSyncWrapper.cs index 16051b8..c58114e 100644 --- a/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientSyncWrapper.cs +++ b/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientSyncWrapper.cs @@ -13,9 +13,10 @@ public class ClientSyncWrapper(AuthenticatedHomeserverGeneric homeserver) : Noti MinimumDelay = TimeSpan.FromMilliseconds(2000), IsInitialSync = false }; + private string _status = "Loading..."; - public ObservableCollection AccountData { get; set; } = new(); + public ObservableCollection AccountData { get; set; } = new(); public ObservableCollection Rooms { get; set; } = new(); public string Status { @@ -29,13 +30,12 @@ public class ClientSyncWrapper(AuthenticatedHomeserverGeneric homeserver) : Noti Status = $"[{DateTime.Now:s}] Syncing..."; await foreach (var response in resp) { Task.Yield(); - Status = $"[{DateTime.Now:s}] {response.Rooms?.Join?.Count ?? 0 + response.Rooms?.Invite?.Count ?? 0 + response.Rooms?.Leave?.Count ?? 0} rooms, {response.AccountData?.Events?.Count ?? 0} account data, {response.ToDevice?.Events?.Count ?? 0} to-device, {response.DeviceLists?.Changed?.Count ?? 0} device lists, {response.Presence?.Events?.Count ?? 0} presence updates"; + Status = + $"[{DateTime.Now:s}] {response.Rooms?.Join?.Count ?? 0 + response.Rooms?.Invite?.Count ?? 0 + response.Rooms?.Leave?.Count ?? 0} rooms, {response.AccountData?.Events?.Count ?? 0} account data, {response.ToDevice?.Events?.Count ?? 0} to-device, {response.DeviceLists?.Changed?.Count ?? 0} device lists, {response.Presence?.Events?.Count ?? 0} presence updates"; await HandleSyncResponse(response); await Task.Yield(); } } - private async Task HandleSyncResponse(SyncResponse resp) { - - } + private async Task HandleSyncResponse(SyncResponse resp) { } } \ No newline at end of file diff --git a/MatrixUtils.Web/Pages/Rooms/Create.razor b/MatrixUtils.Web/Pages/Rooms/Create.razor index 021ad18..051d5af 100644 --- a/MatrixUtils.Web/Pages/Rooms/Create.razor +++ b/MatrixUtils.Web/Pages/Rooms/Create.razor @@ -12,10 +12,10 @@ @*
@JsonString
*@ + table.table-top-first-tr tr td:first-child { + vertical-align: top; + } + @@ -41,7 +41,10 @@ } else { -

(#:@Homeserver.WhoAmI.UserId.Split(':').Last())

+

(# + + :@Homeserver.WhoAmI.UserId.Split(':').Last()) +

} @@ -89,7 +92,8 @@ @@ -105,19 +109,27 @@ - : + + : } @foreach (var user in creationEvent.PowerLevelContentOverride.Users.Keys) { var _user = user; - + } @@ -266,6 +278,7 @@ var instance = (IRoomCreationTemplate)Activator.CreateInstance(x); Presets[instance.Name] = instance.CreateRoomRequest; } + Presets = Presets.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); if (!Presets.ContainsKey("Default")) { @@ -299,7 +312,7 @@ private void InviteMember(string mxid) { if (!creationEvent.InitialState.Any(x => x.Type == "m.room.member" && x.StateKey == mxid) && Homeserver.UserId != mxid) - creationEvent.InitialState.Add(new StateEvent { + creationEvent.InitialState.Add(new MatrixEvent { Type = "m.room.member", StateKey = mxid, TypedContent = new RoomMemberEventContent { @@ -316,7 +329,7 @@ "m.room.server_acl" => "Server ACL", "m.room.avatar" => "Avatar", _ => key - }; + }; private string GetPermissionFriendlyName(string key) => key switch { "m.reaction" => "Send reaction", @@ -331,6 +344,6 @@ "m.room.pinned_events" => "Pin events", "m.room.server_acl" => "Change server ACLs", _ => key - }; + }; } diff --git a/MatrixUtils.Web/Pages/Rooms/PolicyList.razor b/MatrixUtils.Web/Pages/Rooms/PolicyList.razor index 92c6ca5..f2ab186 100644 --- a/MatrixUtils.Web/Pages/Rooms/PolicyList.razor +++ b/MatrixUtils.Web/Pages/Rooms/PolicyList.razor @@ -172,9 +172,9 @@ else { } } - private Dictionary> PolicyEventsByType { get; set; } = new(); + private Dictionary> PolicyEventsByType { get; set; } = new(); - public StateEventResponse? ServerPolicyToMakePermanent { + public MatrixEventResponse? ServerPolicyToMakePermanent { get; set { field = value; @@ -187,9 +187,9 @@ else { private RoomPowerLevelEventContent PowerLevels { get; set; } = null!; public bool CurrentUserIsDraupnir { get; set; } - public Dictionary ActiveKicks { get; set; } = []; + public Dictionary ActiveKicks { get; set; } = []; - private static FrozenSet KnownPolicyTypes = StateEvent.KnownStateEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet(); + private static FrozenSet KnownPolicyTypes = MatrixEvent.KnownEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet(); // event types, unnamed // private static Dictionary PolicyTypes = KnownPolicyTypes @@ -274,14 +274,14 @@ else { if (evt.RawContent is null or { Count: 0 } || string.IsNullOrWhiteSpace(evt.RawContent?["recommendation"]?.GetValue())) { collection.ActivePolicies.Remove(key); if (!collection.RemovedPolicies.TryAdd(key, policyInfo)) { - if (StateEvent.Equals(collection.RemovedPolicies[key].Policy, evt)) continue; + if (MatrixEvent.Equals(collection.RemovedPolicies[key].Policy, evt)) continue; collection.RemovedPolicies[key] = policyInfo; } } else { collection.RemovedPolicies.Remove(key); if (!collection.ActivePolicies.TryAdd(key, policyInfo)) { - if (StateEvent.Equals(collection.ActivePolicies[key].Policy, evt)) continue; + if (MatrixEvent.Equals(collection.ActivePolicies[key].Policy, evt)) continue; collection.ActivePolicies[key] = policyInfo; } } @@ -328,7 +328,7 @@ else { // foreach (var (policyInfo, policyContent) in allPolicies) { // foreach (var (otherPolicyInfo, otherPolicyContent) in allPolicies) { // if (policyInfo.Policy == otherPolicyInfo.Policy) continue; // same event - // if (StateEvent.TypeKeyPairMatches(policyInfo.Policy, otherPolicyInfo.Policy)) { + // if (MatrixEvent.TypeKeyPairMatches(policyInfo.Policy, otherPolicyInfo.Policy)) { // logger.LogWarning("Sanity check failed: Found same type and state key for two different policies: {Policy1} and {Policy2}", policyInfo.Policy.RawContent.ToJson(), otherPolicyInfo.Policy.RawContent.ToJson()); // continue; // same type and state key // } @@ -343,7 +343,7 @@ else { int scanningPolicyCount = 0; var aggregatedPolicies = PolicyCollections.Values - .Aggregate(new List(), (acc, val) => { + .Aggregate(new List(), (acc, val) => { acc.AddRange(val.ActivePolicies.Select(x => x.Value.Policy)); return acc; }); @@ -387,8 +387,8 @@ else { // Console.WriteLine($"Main: got {modifiedPolicyInfos.Count} modified policies from worker, time: {scanSw.Elapsed}"); foreach (var modifiedPolicyInfo in modifiedPolicyInfos) { var original = allPolicyInfos.First(p => p.Policy.EventId == modifiedPolicyInfo.Policy.EventId); - original.DuplicatedBy = aggregatedPolicies.Where(x => modifiedPolicyInfo.DuplicatedBy.Any(y => StateEvent.Equals(x, y))).ToList(); - original.MadeRedundantBy = aggregatedPolicies.Where(x => modifiedPolicyInfo.MadeRedundantBy.Any(y => StateEvent.Equals(x, y))).ToList(); + original.DuplicatedBy = aggregatedPolicies.Where(x => modifiedPolicyInfo.DuplicatedBy.Any(y => MatrixEvent.Equals(x, y))).ToList(); + original.MadeRedundantBy = aggregatedPolicies.Where(x => modifiedPolicyInfo.MadeRedundantBy.Any(y => MatrixEvent.Equals(x, y))).ToList(); modifiedPolicyInfo.DuplicatedBy = modifiedPolicyInfo.MadeRedundantBy = []; // Early dereference if (original.DuplicatedBy.Count > 0) { if (!DuplicateBans.Value.ActivePolicies.ContainsKey((original.Policy.Type, original.Policy.StateKey!))) @@ -476,24 +476,24 @@ else { [return: WorkerTransfer] private static async Task> CheckDuplicatePoliciesAsync(SpawnDev.BlazorJS.JSObjects.String policiesJson, int start, int end) { - var policies = JsonSerializer.Deserialize>(policiesJson.ValueOf()); + var policies = JsonSerializer.Deserialize>(policiesJson.ValueOf()); Console.WriteLine($"Got request to check duplicate policies in range {start} to {end} (length: {end - start}), {policiesJson.ValueOf().Length} bytes of JSON ({policies!.Count} policies)"); return await CheckDuplicatePoliciesAsync(policies!, start .. end); } [return: WorkerTransfer] private static async Task> CheckDuplicatePoliciesAsync(string policiesJson, int start, int end) { - var policies = JsonSerializer.Deserialize>(policiesJson); + var policies = JsonSerializer.Deserialize>(policiesJson); Console.WriteLine($"Got request to check duplicate policies in range {start} to {end} (length: {end - start}), {policiesJson.Length} bytes of JSON ({policies!.Count} policies)"); return await CheckDuplicatePoliciesAsync(policies!, start .. end); } [return: WorkerTransfer] - private static Task> CheckDuplicatePoliciesAsync(List policies, int start, int end) + private static Task> CheckDuplicatePoliciesAsync(List policies, int start, int end) => CheckDuplicatePoliciesAsync(policies, start .. end); [return: WorkerTransfer] - private static async Task> CheckDuplicatePoliciesAsync(List policies, Range range) { + private static async Task> CheckDuplicatePoliciesAsync(List policies, Range range) { var sw = Stopwatch.StartNew(); var jsConsole = App.Host.Services.GetService()!; Console.WriteLine($"Processing policies in range {range} ({range.GetOffsetAndLength(policies.Count).Length}) with {policies.Count} total policies"); @@ -504,12 +504,12 @@ else { var modifiedPolicies = new List(); foreach (var (policyEvent, policyContent) in toCheck) { - List duplicatedBy = []; - List madeRedundantBy = []; + List duplicatedBy = []; + List madeRedundantBy = []; foreach (var (otherPolicyEvent, otherPolicyContent) in allPolicies) { if (policyEvent == otherPolicyEvent) continue; // same event - if (StateEvent.TypeKeyPairMatches(policyEvent, otherPolicyEvent)) { + if (MatrixEvent.TypeKeyPairMatches(policyEvent, otherPolicyEvent)) { // logger.LogWarning("Sanity check failed: Found same type and state key for two different policies: {Policy1} and {Policy2}", policyInfo.Policy.RawContent.ToJson(), otherPolicyInfo.Policy.RawContent.ToJson()); Console.WriteLine($"Sanity check failed: Found same type and state key for two different policies: {policyEvent.RawContent.ToJson()} and {otherPolicyEvent.RawContent.ToJson()}"); continue; // same type and state key @@ -561,7 +561,7 @@ else { foreach (var type in KnownPolicyTypes) { if (!PolicyEventsByType.ContainsKey(type)) PolicyEventsByType.Add(type, new List - (16000)); + (16000)); } int count = 0; @@ -573,9 +573,9 @@ else { e1 = _spsw.Elapsed; var targetPolicies = PolicyEventsByType[state.MappedType]; e2 = _spsw.Elapsed; - if (!firstLoad && targetPolicies.FirstOrDefault(x => StateEvent.TypeKeyPairMatches(x, state)) is { } evt) { + if (!firstLoad && targetPolicies.FirstOrDefault(x => MatrixEvent.TypeKeyPairMatches(x, state)) is { } evt) { e3 = _spsw.Elapsed; - if (StateEvent.Equals(evt, state)) { + if (MatrixEvent.Equals(evt, state)) { if (count % 100 == 0) { await Task.Delay(10); await Task.Yield(); @@ -613,15 +613,15 @@ else { logger.LogInformation("LoadStatesAsync: yield finished in {SwElapsed}", sw.Elapsed); } - private List GetPolicyEventsByType(Type type) => PolicyEventsByType.ContainsKey(type) ? PolicyEventsByType[type] : []; + private List GetPolicyEventsByType(Type type) => PolicyEventsByType.ContainsKey(type) ? PolicyEventsByType[type] : []; - // private List GetValidPolicyEventsByType(Type type) => GetPolicyEventsByType(type) + // private List GetValidPolicyEventsByType(Type type) => GetPolicyEventsByType(type) // .Where(x => !string.IsNullOrWhiteSpace(x.RawContent?["recommendation"]?.GetValue())).ToList(); // - // private List GetInvalidPolicyEventsByType(Type type) => GetPolicyEventsByType(type) + // private List GetInvalidPolicyEventsByType(Type type) => GetPolicyEventsByType(type) // .Where(x => x.RawContent is { Count: > 0 } && string.IsNullOrWhiteSpace(x.RawContent?["recommendation"]?.GetValue())).ToList(); // - // private List GetRemovedPolicyEventsByType(Type type) => GetPolicyEventsByType(type) + // private List GetRemovedPolicyEventsByType(Type type) => GetPolicyEventsByType(type) // .Where(x => x.RawContent is null or { Count: 0 }).ToList(); private string? GetPolicyTypeNameOrNull(Type type) => type.GetFriendlyNamePluralOrNull() @@ -637,14 +637,14 @@ else { public required Dictionary<(string Type, string StateKey), PolicyInfo> ActivePolicies { get; set; } - // public Dictionary<(string Type, string StateKey), StateEventResponse> InvalidPolicies { get; set; } + // public Dictionary<(string Type, string StateKey), MatrixEventResponse> InvalidPolicies { get; set; } public required Dictionary<(string Type, string StateKey), PolicyInfo> RemovedPolicies { get; set; } public required FrozenDictionary PropertiesToDisplay { get; set; } public class PolicyInfo { - public required StateEventResponse Policy { get; init; } - public required List MadeRedundantBy { get; set; } - public required List DuplicatedBy { get; set; } + public required MatrixEventResponse Policy { get; init; } + public required List MadeRedundantBy { get; set; } + public required List DuplicatedBy { get; set; } } public enum SpecialViewType { diff --git a/MatrixUtils.Web/Pages/Rooms/PolicyList.razor.cs b/MatrixUtils.Web/Pages/Rooms/PolicyList.razor.cs index 0106c6e..6f45041 100644 --- a/MatrixUtils.Web/Pages/Rooms/PolicyList.razor.cs +++ b/MatrixUtils.Web/Pages/Rooms/PolicyList.razor.cs @@ -8,12 +8,11 @@ using SpawnDev.BlazorJS.WebWorkers; namespace MatrixUtils.Web.Pages.Rooms; public partial class PolicyList { - #region Draupnir interop private SemaphoreSlim ss = new(16, 16); - private async Task DraupnirKickMatching(StateEventResponse policy) { + private async Task DraupnirKickMatching(MatrixEventResponse policy) { try { var content = policy.TypedContent! as PolicyRuleEventContent; if (content is null) return; @@ -94,7 +93,7 @@ public partial class PolicyList { #region Nasty, nasty internals, please ignore! private static class NastyInternalsPleaseIgnore { - public static async Task ExecuteKickWithWasmWorkers(WebWorkerService workerService, AuthenticatedHomeserverGeneric hs, StateEventResponse evt, List roomIds) { + public static async Task ExecuteKickWithWasmWorkers(WebWorkerService workerService, AuthenticatedHomeserverGeneric hs, MatrixEventResponse evt, List roomIds) { try { // var tasks = roomIds.Select(roomId => workerService.TaskPool.Invoke(ExecuteKickInternal, hs.WellKnownUris.Client, hs.AccessToken, roomId, content.Entity)).ToList(); var tasks = roomIds.Select(roomId => workerService.TaskPool.Invoke(ExecuteKickInternal2, hs.WellKnownUris, hs.AccessToken, roomId, evt)).ToList(); @@ -131,7 +130,7 @@ public partial class PolicyList { } } - private async static Task ExecuteKickInternal2(HomeserverResolverService.WellKnownUris wellKnownUris, string accessToken, string roomId, StateEventResponse policy) { + private async static Task ExecuteKickInternal2(HomeserverResolverService.WellKnownUris wellKnownUris, string accessToken, string roomId, MatrixEventResponse policy) { Console.WriteLine($"Checking {roomId}..."); Console.WriteLine(policy.EventId); } @@ -140,5 +139,4 @@ public partial class PolicyList { #endregion #endregion - } \ No newline at end of file diff --git a/MatrixUtils.Web/Pages/Rooms/PolicyList2.razor b/MatrixUtils.Web/Pages/Rooms/PolicyList2.razor index 5d5bb5d..ac918a8 100644 --- a/MatrixUtils.Web/Pages/Rooms/PolicyList2.razor +++ b/MatrixUtils.Web/Pages/Rooms/PolicyList2.razor @@ -15,7 +15,11 @@

Policy list editor - Editing @RoomId


@* *@ -Create new policy +Create new policy + @if (Loading) {

Loading...

@@ -71,14 +75,22 @@ else { }
@if (PowerLevels.UserHasStatePermission(Homeserver.WhoAmI.UserId, policy.Type)) { - Edit + Edit + Remove @if (policy.IsLegacyType) { Update policy type } @if (PolicyTypeIds[typeof(ServerPolicyRuleEventContent)].Contains(policy.EventId)) { - Make permanent (wildcard) + Make permanent (wildcard) + @if (CurrentUserIsDraupnir) { Kick matching users } @@ -144,12 +156,12 @@ else { public string RoomId { get; set; } private bool _enableAvatars; - private StateEventResponse? _currentlyEditingEvent; - private StateEventResponse? _serverPolicyToMakePermanent; + private MatrixEventResponse? _currentlyEditingEvent; + private MatrixEventResponse? _serverPolicyToMakePermanent; - private Dictionary> PolicyEventsByType { get; set; } = new(); + private Dictionary> PolicyEventsByType { get; set; } = new(); - private StateEventResponse? CurrentlyEditingEvent { + private MatrixEventResponse? CurrentlyEditingEvent { get => _currentlyEditingEvent; set { _currentlyEditingEvent = value; @@ -157,7 +169,7 @@ else { } } - private StateEventResponse? ServerPolicyToMakePermanent { + private MatrixEventResponse? ServerPolicyToMakePermanent { get => _serverPolicyToMakePermanent; set { _serverPolicyToMakePermanent = value; @@ -197,12 +209,12 @@ else { StateHasChanged(); } - private List GetPolicyEventsByType(Type type) => PolicyEventsByType.ContainsKey(type) ? PolicyEventsByType[type] : []; + private List GetPolicyEventsByType(Type type) => PolicyEventsByType.ContainsKey(type) ? PolicyEventsByType[type] : []; - private List GetValidPolicyEventsByType(Type type) => GetPolicyEventsByType(type) + private List GetValidPolicyEventsByType(Type type) => GetPolicyEventsByType(type) .Where(x => !string.IsNullOrWhiteSpace(x.RawContent?["recommendation"]?.GetValue())).ToList(); - private List GetInvalidPolicyEventsByType(Type type) => GetPolicyEventsByType(type) + private List GetInvalidPolicyEventsByType(Type type) => GetPolicyEventsByType(type) .Where(x => string.IsNullOrWhiteSpace(x.RawContent?["recommendation"]?.GetValue())).ToList(); private string? GetPolicyTypeNameOrNull(Type type) => type.GetFriendlyNamePluralOrNull() @@ -211,24 +223,24 @@ else { private string GetPolicyTypeName(Type type) => GetPolicyTypeNameOrNull(type) ?? type.Name; - private async Task RemovePolicyAsync(StateEventResponse policyEvent) { + private async Task RemovePolicyAsync(MatrixEventResponse policyEvent) { await Room.SendStateEventAsync(policyEvent.Type, policyEvent.StateKey.UrlEncode(), new { }); PolicyEventsByType[policyEvent.MappedType].Remove(policyEvent); await LoadStatesAsync(); } - private async Task UpdatePolicyAsync(StateEventResponse policyEvent) { + private async Task UpdatePolicyAsync(MatrixEventResponse policyEvent) { await Room.SendStateEventAsync(policyEvent.Type, policyEvent.StateKey.UrlEncode(), policyEvent.RawContent); CurrentlyEditingEvent = null; await LoadStatesAsync(); } - private async Task UpgradePolicyAsync(StateEventResponse policyEvent) { + private async Task UpgradePolicyAsync(MatrixEventResponse policyEvent) { policyEvent.RawContent["upgraded_from_type"] = policyEvent.Type; await LoadStatesAsync(); } - private static FrozenSet KnownPolicyTypes = StateEvent.KnownStateEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet(); + private static FrozenSet KnownPolicyTypes = MatrixEvent.KnownEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet(); // event types, unnamed private static Dictionary PolicyTypes = KnownPolicyTypes diff --git a/MatrixUtils.Web/Pages/Rooms/PolicyListComponents/PolicyListEditorHeader.razor b/MatrixUtils.Web/Pages/Rooms/PolicyListComponents/PolicyListEditorHeader.razor index 8585561..b57beae 100644 --- a/MatrixUtils.Web/Pages/Rooms/PolicyListComponents/PolicyListEditorHeader.razor +++ b/MatrixUtils.Web/Pages/Rooms/PolicyListComponents/PolicyListEditorHeader.razor @@ -55,7 +55,7 @@ private string? RoomAlias { get; set; } private string? DraupnirShortcode { get; set; } - private StateEventResponse? CurrentlyEditingEvent { + private MatrixEventResponse? CurrentlyEditingEvent { get; set { field = value; @@ -81,7 +81,7 @@ StateHasChanged(); } - private async Task UpdatePolicyAsync(StateEventResponse evt) { + private async Task UpdatePolicyAsync(MatrixEventResponse evt) { Console.WriteLine("UpdatePolicyAsync in PolicyListEditorHeader not yet implemented!"); } diff --git a/MatrixUtils.Web/Pages/Rooms/PolicyListComponents/PolicyListRowComponent.razor b/MatrixUtils.Web/Pages/Rooms/PolicyListComponents/PolicyListRowComponent.razor index cd432c9..3ded78f 100644 --- a/MatrixUtils.Web/Pages/Rooms/PolicyListComponents/PolicyListRowComponent.razor +++ b/MatrixUtils.Web/Pages/Rooms/PolicyListComponents/PolicyListRowComponent.razor @@ -99,7 +99,7 @@ [Parameter] public required Action PolicyCollectionStateHasChanged { get; set; } - private StateEventResponse Policy => PolicyInfo.Policy; + private MatrixEventResponse Policy => PolicyInfo.Policy; private bool IsEditing { get; @@ -152,8 +152,8 @@ if (PolicyInfo.DuplicatedBy.Count > 0) { foreach (var evt in PolicyInfo.DuplicatedBy) { var matchingEntry = PolicyCollection.ActivePolicies - .FirstOrDefault(x => StateEvent.Equals(x.Value.Policy, evt)).Value; - var removals = matchingEntry.DuplicatedBy.RemoveAll(x => StateEvent.Equals(x, Policy)); + .FirstOrDefault(x => MatrixEvent.Equals(x.Value.Policy, evt)).Value; + var removals = matchingEntry.DuplicatedBy.RemoveAll(x => MatrixEvent.Equals(x, Policy)); Console.WriteLine($"Removed {removals} duplicates from {evt.EventId}, matching entry: {matchingEntry.ToJson()}"); if (PolicyCollection.ViewType == PolicyList.PolicyCollection.SpecialViewType.Duplicates && matchingEntry.DuplicatedBy.Count == 0) { PolicyCollection.ActivePolicies.Remove((matchingEntry.Policy.Type, matchingEntry.Policy.StateKey)); @@ -169,8 +169,8 @@ if (PolicyInfo.MadeRedundantBy.Count > 0) { foreach (var evt in PolicyInfo.MadeRedundantBy) { var matchingEntry = PolicyCollection.ActivePolicies - .FirstOrDefault(x => StateEvent.Equals(x.Value.Policy, evt)).Value; - var removals = matchingEntry.MadeRedundantBy.RemoveAll(x => StateEvent.Equals(x, Policy)); + .FirstOrDefault(x => MatrixEvent.Equals(x.Value.Policy, evt)).Value; + var removals = matchingEntry.MadeRedundantBy.RemoveAll(x => MatrixEvent.Equals(x, Policy)); Console.WriteLine($"Removed {removals} redundants from {evt.EventId}, matching entry: {matchingEntry.ToJson()}"); } @@ -186,7 +186,7 @@ // await LoadStatesAsync(); } - private async Task UpdatePolicyAsync(StateEventResponse evt) { + private async Task UpdatePolicyAsync(MatrixEventResponse evt) { await Room.SendStateEventAsync(Policy.Type, Policy.StateKey, Policy.RawContent); // CurrentlyEditingEvent = null; // await LoadStatesAsync(); diff --git a/MatrixUtils.Web/Pages/Rooms/PolicyLists.razor b/MatrixUtils.Web/Pages/Rooms/PolicyLists.razor index 52c5f30..a84ef8c 100644 --- a/MatrixUtils.Web/Pages/Rooms/PolicyLists.razor +++ b/MatrixUtils.Web/Pages/Rooms/PolicyLists.razor @@ -188,7 +188,7 @@ Server } - public static async Task FromRoom(GenericRoom room, List? state = null, bool legacy = false) { + public static async Task FromRoom(GenericRoom room, List? state = null, bool legacy = false) { state ??= await room.GetFullStateAsListAsync(); return new RoomInfo() { Room = room, diff --git a/MatrixUtils.Web/Pages/Rooms/RoomCreateComponents/RoomCreateInitialStateOptions.razor b/MatrixUtils.Web/Pages/Rooms/RoomCreateComponents/RoomCreateInitialStateOptions.razor index 99facbf..2b1d90a 100644 --- a/MatrixUtils.Web/Pages/Rooms/RoomCreateComponents/RoomCreateInitialStateOptions.razor +++ b/MatrixUtils.Web/Pages/Rooms/RoomCreateComponents/RoomCreateInitialStateOptions.razor @@ -5,7 +5,7 @@
- + } else {
Preset:
@* *@
-
+ +
- +
: - + + : + +
Initial room state: - @foreach (var (displayName, events) in new Dictionary>() { + @foreach (var (displayName, events) in new Dictionary>() { { "Important room state (before final access rules)", roomBuilder.ImportantState }, { "Additional room state (after final access rules)", roomBuilder.InitialState }, }) { @@ -47,10 +47,10 @@ @* if (string.IsNullOrWhiteSpace(json)) *@ @* events.Remove(initialState); *@ @* else *@ - @* events.Replace(initialState, JsonSerializer.Deserialize(json)); *@ + @* events.Replace(initialState, JsonSerializer.Deserialize(json)); *@ @* StateHasChanged(); *@ @* })"> *@ - +
} @@ -71,7 +71,7 @@ [Parameter] public AuthenticatedHomeserverGeneric Homeserver { get; set; } - private RenderFragment GetRemoveButton(List events, StateEvent initialState) { + private RenderFragment GetRemoveButton(List events, MatrixEvent initialState) { return @ ()!; - // - // foreach (var stateEvent in States) { - // if (stateEvent.Type == "m.space.child") { - // // if (stateEvent.Content.ToJson().Length < 5) return; - // var roomId = stateEvent.StateKey; - // var room = hs.GetRoom(roomId); - // if (room is not null) { - // Rooms.Add(room); - // } - // } - // else if (stateEvent.Type == "m.room.member") { - // var serverName = stateEvent.StateKey.Split(':').Last(); - // if (!ServersInSpace.Contains(serverName)) { - // ServersInSpace.Add(serverName); - // } - // } - // } - - // if(state.Value.TryGetProperty("Type", out var Type)) - // { - // } - // else - // { - // //this is fine, apprently... - // //Console.WriteLine($"Room {room.RoomId} has no Content.Type in m.room.create!"); - // } - - // await base.OnInitializedAsync(); + // var state = await Room.GetStateAsync(""); + // if (state is not null) { + // // Console.WriteLine(state.Value.ToJson()); + // States = state.Value.Deserialize()!; + // + // foreach (var stateEvent in States) { + // if (stateEvent.Type == "m.space.child") { + // // if (stateEvent.Content.ToJson().Length < 5) return; + // var roomId = stateEvent.StateKey; + // var room = hs.GetRoom(roomId); + // if (room is not null) { + // Rooms.Add(room); + // } + // } + // else if (stateEvent.Type == "m.room.member") { + // var serverName = stateEvent.StateKey.Split(':').Last(); + // if (!ServersInSpace.Contains(serverName)) { + // ServersInSpace.Add(serverName); + // } + // } + // } + + // if(state.Value.TryGetProperty("Type", out var Type)) + // { + // } + // else + // { + // //this is fine, apprently... + // //Console.WriteLine($"Room {room.RoomId} has no Content.Type in m.room.create!"); + // } + + // await base.OnInitializedAsync(); } private async Task JoinAllRooms() { @@ -124,13 +127,14 @@ var joined = false; while (!joined) { var ce = await room.GetCreateEventAsync(); - if(ce is null) continue; + if (ce is null) continue; if (ce.Type == "m.space") { - var children = room.AsSpace().GetChildrenAsync(false); - await foreach (var child in children) { - JoinRecursive(child.RoomId); - } + var children = room.AsSpace().GetChildrenAsync(false); + await foreach (var child in children) { + JoinRecursive(child.RoomId); + } } + joined = true; await Task.Delay(1000); } @@ -138,7 +142,6 @@ catch (Exception e) { Console.WriteLine(e); } - } private async Task AddNewRoom() { diff --git a/MatrixUtils.Web/Pages/Rooms/StateEditor.razor b/MatrixUtils.Web/Pages/Rooms/StateEditor.razor index 51cb265..47146bc 100644 --- a/MatrixUtils.Web/Pages/Rooms/StateEditor.razor +++ b/MatrixUtils.Web/Pages/Rooms/StateEditor.razor @@ -37,8 +37,8 @@ [Parameter] public string? RoomId { get; set; } - public List FilteredEvents { get; set; } = new(); - public List Events { get; set; } = new(); + public List FilteredEvents { get; set; } = new(); + public List Events { get; set; } = new(); public string status = ""; protected override async Task OnInitializedAsync() { @@ -58,7 +58,7 @@ var StateLoaded = 0; var response = (hs.GetRoom(RoomId)).GetFullStateAsync(); await foreach (var _ev in response) { - // var e = new StateEventResponse { + // var e = new MatrixEventResponse { // Type = _ev.Type, // StateKey = _ev.StateKey, // OriginServerTs = _ev.OriginServerTs, @@ -68,6 +68,7 @@ if (string.IsNullOrEmpty(_ev.StateKey)) { FilteredEvents.Add(_ev); } + StateLoaded++; if (!((DateTime.Now - _lastUpdate).TotalMilliseconds > 100)) continue; @@ -103,11 +104,12 @@ public string content { get; set; } public long origin_server_ts { get; set; } public string state_key { get; set; } + public string type { get; set; } - // public string Sender { get; set; } - // public string EventId { get; set; } - // public string UserId { get; set; } - // public string ReplacesState { get; set; } + // public string Sender { get; set; } + // public string EventId { get; set; } + // public string UserId { get; set; } + // public string ReplacesState { get; set; } } public bool ShowMembershipEvents { diff --git a/MatrixUtils.Web/Pages/Rooms/StateViewer.razor b/MatrixUtils.Web/Pages/Rooms/StateViewer.razor index c8b87d3..16b1d3d 100644 --- a/MatrixUtils.Web/Pages/Rooms/StateViewer.razor +++ b/MatrixUtils.Web/Pages/Rooms/StateViewer.razor @@ -12,20 +12,20 @@ - - - - - - - @foreach (var stateEvent in FilteredEvents.Where(x => x.StateKey == "").OrderBy(x => x.OriginServerTs)) { - - + + - } + + + @foreach (var stateEvent in FilteredEvents.Where(x => x.StateKey == "").OrderBy(x => x.OriginServerTs)) { + + + + + }
TypeContent
@stateEvent.Type -
@stateEvent.RawContent.ToJson()
-
TypeContent
@stateEvent.Type +
@stateEvent.RawContent.ToJson()
+
@@ -34,20 +34,20 @@ @group.Key - - - - - - - @foreach (var stateEvent in group.OrderBy(x => x.OriginServerTs)) { - - + + - } + + + @foreach (var stateEvent in group.OrderBy(x => x.OriginServerTs)) { + + + + + }
TypeContent
@stateEvent.Type -
@stateEvent.RawContent.ToJson()
-
TypeContent
@stateEvent.Type +
@stateEvent.RawContent.ToJson()
+
@@ -64,8 +64,8 @@ [Parameter] public string? RoomId { get; set; } - public List FilteredEvents { get; set; } = new(); - public List Events { get; set; } = new(); + public List FilteredEvents { get; set; } = new(); + public List Events { get; set; } = new(); public string status = ""; protected override async Task OnInitializedAsync() { @@ -88,6 +88,7 @@ if (string.IsNullOrEmpty(_ev.StateKey)) { FilteredEvents.Add(_ev); } + StateLoaded++; if (!((DateTime.Now - _lastUpdate).TotalMilliseconds > 100)) continue; diff --git a/MatrixUtils.Web/Pages/Rooms/Timeline.razor b/MatrixUtils.Web/Pages/Rooms/Timeline.razor index 2af819b..f9137b0 100644 --- a/MatrixUtils.Web/Pages/Rooms/Timeline.razor +++ b/MatrixUtils.Web/Pages/Rooms/Timeline.razor @@ -22,7 +22,7 @@ public string RoomId { get; set; } private List Events { get; } = new(); - private List RawEvents { get; } = new(); + private List RawEvents { get; } = new(); private AuthenticatedHomeserverGeneric? Homeserver { get; set; } @@ -44,9 +44,9 @@ await base.OnInitializedAsync(); } - // private StateEventResponse GetProfileEventBefore(StateEventResponse Event) => Events.TakeWhile(x => x != Event).Last(e => e.Type == RoomMemberEventContent.EventId && e.StateKey == Event.Sender); + // private MatrixEventResponse GetProfileEventBefore(MatrixEventResponse Event) => Events.TakeWhile(x => x != Event).Last(e => e.Type == RoomMemberEventContent.EventId && e.StateKey == Event.Sender); - private Type ComponentType(StateEvent Event) => Event.Type switch { + private Type ComponentType(MatrixEvent Event) => Event.Type switch { RoomCanonicalAliasEventContent.EventId => typeof(TimelineCanonicalAliasItem), RoomHistoryVisibilityEventContent.EventId => typeof(TimelineHistoryVisibilityItem), RoomTopicEventContent.EventId => typeof(TimelineRoomTopicItem), @@ -57,9 +57,9 @@ // RoomMessageReactionEventContent.EventId => typeof(ComponentBase), _ => typeof(TimelineUnknownItem) }; - + private class TimelineEventItem : ComponentBase { - public StateEventResponse Event { get; set; } + public MatrixEventResponse Event { get; set; } public Type Type { get; set; } } diff --git a/MatrixUtils.Web/Pages/StreamTest.razor b/MatrixUtils.Web/Pages/StreamTest.razor index 7740596..949bddc 100644 --- a/MatrixUtils.Web/Pages/StreamTest.razor +++ b/MatrixUtils.Web/Pages/StreamTest.razor @@ -48,9 +48,9 @@ var members = roomState.Where(x => x.Type == RoomMemberEventContent.EventId).ToList(); Console.WriteLine($"Got {members.Count()} members"); var ss = new SemaphoreSlim(1, 1); - foreach (var stateEventResponse in members) { - // Console.WriteLine(stateEventResponse.ToJson()); - var mc = stateEventResponse.TypedContent as RoomMemberEventContent; + foreach (var MatrixEventResponse in members) { + // Console.WriteLine(MatrixEventResponse.ToJson()); + var mc = MatrixEventResponse.TypedContent as RoomMemberEventContent; if (!string.IsNullOrWhiteSpace(mc?.AvatarUrl)) { var uri = mc.AvatarUrl[6..].Split('/'); var url = $"/_matrix/media/v3/download/{uri[0]}/{uri[1]}"; diff --git a/MatrixUtils.Web/Pages/Tools/Info/PolicyListActivity.razor b/MatrixUtils.Web/Pages/Tools/Info/PolicyListActivity.razor index bfd5fd3..ba8036c 100644 --- a/MatrixUtils.Web/Pages/Tools/Info/PolicyListActivity.razor +++ b/MatrixUtils.Web/Pages/Tools/Info/PolicyListActivity.razor @@ -74,7 +74,7 @@ else } //use timeline - var types = StateEventResponse.KnownStateEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))); + var types = MatrixEvent.KnownEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))); var filter = new SyncFilter.EventFilter(types: types.SelectMany(x => x.GetCustomAttributes().Select(y => y.EventName)).ToList()); var timeline = room.GetManyMessagesAsync(limit: int.MaxValue, chunkSize: 2500, filter: filter.ToJson(indent: false, ignoreNull: true)); await foreach (var response in timeline) { @@ -119,10 +119,10 @@ else private readonly struct StateEventEntry { public required DateTime Timestamp { get; init; } public required StateEventTransition State { get; init; } - public required StateEventResponse Event { get; init; } - public required StateEventResponse? Previous { get; init; } + public required MatrixEventResponse Event { get; init; } + public required MatrixEventResponse? Previous { get; init; } - public void Deconstruct(out StateEventTransition transition, out StateEventResponse evt, out StateEventResponse? prev) { + public void Deconstruct(out StateEventTransition transition, out MatrixEventResponse evt, out MatrixEventResponse? prev) { transition = State; evt = Event; prev = Previous; diff --git a/MatrixUtils.Web/Pages/Tools/Info/SessionCount.razor b/MatrixUtils.Web/Pages/Tools/Info/SessionCount.razor index dc5333b..76ff629 100644 --- a/MatrixUtils.Web/Pages/Tools/Info/SessionCount.razor +++ b/MatrixUtils.Web/Pages/Tools/Info/SessionCount.razor @@ -60,7 +60,7 @@ private ObservableCollection log { get; set; } = new(); List hss { get; set; } = new(); ObservableCollection rooms { get; set; } = new(); - Dictionary> roomMembers { get; set; } = new(); + Dictionary> roomMembers { get; set; } = new(); Dictionary> matches = new(); private string UserIdString { @@ -147,7 +147,7 @@ private class Matches { public GenericRoom Room; - public StateEventResponse Event; + public MatrixEventResponse Event; // public } diff --git a/MatrixUtils.Web/Pages/Tools/Moderation/FindUsersByRegex.razor b/MatrixUtils.Web/Pages/Tools/Moderation/FindUsersByRegex.razor index 5ad9de4..9139561 100644 --- a/MatrixUtils.Web/Pages/Tools/Moderation/FindUsersByRegex.razor +++ b/MatrixUtils.Web/Pages/Tools/Moderation/FindUsersByRegex.razor @@ -145,7 +145,7 @@ private class Match { public GenericRoom Room; - public StateEventResponse Event; + public MatrixEventResponse Event; public string RoomName { get; set; } } diff --git a/MatrixUtils.Web/Pages/Tools/Moderation/MembershipHistory.razor b/MatrixUtils.Web/Pages/Tools/Moderation/MembershipHistory.razor index 11c4a80..ec1d190 100644 --- a/MatrixUtils.Web/Pages/Tools/Moderation/MembershipHistory.razor +++ b/MatrixUtils.Web/Pages/Tools/Moderation/MembershipHistory.razor @@ -31,23 +31,23 @@

Hide all + ShowJoins = ShowLeaves = ShowKnocks = ShowInvites = ShowBans = false; + StateHasChanged(); + })">Hide all Show all + ShowJoins = ShowLeaves = ShowKnocks = ShowInvites = ShowBans = true; + StateHasChanged(); + })">Show all Toggle all + ShowJoins ^= true; + ShowLeaves ^= true; + ShowKnocks ^= true; + ShowInvites ^= true; + ShowBans ^= true; + StateHasChanged(); + })">Toggle all

@@ -56,25 +56,25 @@ kicks unbans profile updates -

- - - invite actions - - accepted - rejected - retracted -
-
- - - knock actions - - accepted - rejected - retracted -
- } +
+ + + invite actions + + accepted + rejected + retracted +
+
+ + + knock actions + + accepted + rejected + retracted +
+}

@if (DoDisambiguate) {

@@ -130,29 +130,29 @@

Un-disambiguate all + DoDisambiguate = DisambiguateProfileUpdates = DisambiguateKicks = DisambiguateUnbans = DisambiguateInviteAccepted = DisambiguateInviteRejected = DisambiguateInviteRetracted = DisambiguateKnockAccepted = DisambiguateKnockRejected = DisambiguateKnockRetracted = DisambiguateKnockActions = DisambiguateInviteActions = false; + StateHasChanged(); + })">Un-disambiguate all Disambiguate all + DoDisambiguate = DisambiguateProfileUpdates = DisambiguateKicks = DisambiguateUnbans = DisambiguateInviteAccepted = DisambiguateInviteRejected = DisambiguateInviteRetracted = DisambiguateKnockAccepted = DisambiguateKnockRejected = DisambiguateKnockRetracted = DisambiguateKnockActions = DisambiguateInviteActions = true; + StateHasChanged(); + })">Disambiguate all Toggle all + DisambiguateProfileUpdates ^= true; + DisambiguateKicks ^= true; + DisambiguateUnbans ^= true; + DisambiguateInviteAccepted ^= true; + DisambiguateInviteRejected ^= true; + DisambiguateInviteRetracted ^= true; + DisambiguateKnockAccepted ^= true; + DisambiguateKnockRejected ^= true; + DisambiguateKnockRetracted ^= true; + DisambiguateKnockActions ^= true; + DisambiguateInviteActions ^= true; + StateHasChanged(); + })">Toggle all

} @@ -306,18 +306,61 @@ private bool ShowBans { get; set; } = true; private bool DoDisambiguate { get; set; } = true; - private bool DisambiguateProfileUpdates { get => field && DoDisambiguate; set; } = true; - private bool DisambiguateKicks { get => field && DoDisambiguate; set; } = true; - private bool DisambiguateUnbans { get => field && DoDisambiguate; set; } = true; - private bool DisambiguateInviteAccepted { get => field && DoDisambiguate && DisambiguateInviteActions; set; } = true; - private bool DisambiguateInviteRejected { get => field && DoDisambiguate && DisambiguateInviteActions; set; } = true; - private bool DisambiguateInviteRetracted { get => field && DoDisambiguate && DisambiguateInviteActions; set; } = true; - private bool DisambiguateKnockAccepted { get => field && DoDisambiguate && DisambiguateKnockActions; set; } = true; - private bool DisambiguateKnockRejected { get => field && DoDisambiguate && DisambiguateKnockActions; set; } = true; - private bool DisambiguateKnockRetracted { get => field && DoDisambiguate && DisambiguateKnockActions; set; } = true; - - private bool DisambiguateKnockActions { get => field && DoDisambiguate; set; } = true; - private bool DisambiguateInviteActions { get => field && DoDisambiguate; set; } = true; + + private bool DisambiguateProfileUpdates { + get => field && DoDisambiguate; + set; + } = true; + + private bool DisambiguateKicks { + get => field && DoDisambiguate; + set; + } = true; + + private bool DisambiguateUnbans { + get => field && DoDisambiguate; + set; + } = true; + + private bool DisambiguateInviteAccepted { + get => field && DoDisambiguate && DisambiguateInviteActions; + set; + } = true; + + private bool DisambiguateInviteRejected { + get => field && DoDisambiguate && DisambiguateInviteActions; + set; + } = true; + + private bool DisambiguateInviteRetracted { + get => field && DoDisambiguate && DisambiguateInviteActions; + set; + } = true; + + private bool DisambiguateKnockAccepted { + get => field && DoDisambiguate && DisambiguateKnockActions; + set; + } = true; + + private bool DisambiguateKnockRejected { + get => field && DoDisambiguate && DisambiguateKnockActions; + set; + } = true; + + private bool DisambiguateKnockRetracted { + get => field && DoDisambiguate && DisambiguateKnockActions; + set; + } = true; + + private bool DisambiguateKnockActions { + get => field && DoDisambiguate; + set; + } = true; + + private bool DisambiguateInviteActions { + get => field && DoDisambiguate; + set; + } = true; private bool ShowProfileUpdates { get => field && DisambiguateProfileUpdates; @@ -399,7 +442,7 @@ #endregion private ObservableCollection Log { get; set; } = new(); - private List Memberships { get; set; } = []; + private List Memberships { get; set; } = []; private AuthenticatedHomeserverGeneric Homeserver { get; set; } [Parameter, SupplyParameterFromQuery(Name = "room")] @@ -444,10 +487,10 @@ private readonly struct MembershipEntry { public required MembershipTransition State { get; init; } - public required StateEventResponse Event { get; init; } - public required StateEventResponse? Previous { get; init; } + public required MatrixEventResponse Event { get; init; } + public required MatrixEventResponse? Previous { get; init; } - public void Deconstruct(out MembershipTransition transition, out StateEventResponse evt, out StateEventResponse? prev) { + public void Deconstruct(out MembershipTransition transition, out MatrixEventResponse evt, out MatrixEventResponse? prev) { transition = State; evt = Event; prev = Previous; @@ -474,7 +517,7 @@ KnockRetracted } - private static IEnumerable GetTransitions(List evts) { + private static IEnumerable GetTransitions(List evts) { Dictionary transitions = new(); foreach (var evt in evts.OrderBy(x => x.OriginServerTs)) { var content = evt.TypedContent as RoomMemberEventContent ?? throw new InvalidOperationException("Event is not a RoomMemberEventContent!"); @@ -528,7 +571,7 @@ { MembershipTransition.KnockRejected, MembershipTransition.Leave }, { MembershipTransition.KnockRetracted, MembershipTransition.Leave } }.ToFrozenDictionary(); - + foreach (var entry in entries) { if (!DoDisambiguate) { yield return entry; diff --git a/MatrixUtils.Web/Pages/Tools/Moderation/RoomIntersections.razor b/MatrixUtils.Web/Pages/Tools/Moderation/RoomIntersections.razor index ee77532..a8ae603 100644 --- a/MatrixUtils.Web/Pages/Tools/Moderation/RoomIntersections.razor +++ b/MatrixUtils.Web/Pages/Tools/Moderation/RoomIntersections.razor @@ -55,7 +55,7 @@
@sets.Item2[0].Room.RoomId @((sets.Item2[i].Member.TypedContent as RoomMemberEventContent).Membership) @(roomNames.ContainsKey(sets.Item2[i].Room) ? roomNames[sets.Item2[i].Room] : "")@(roomAliasses.ContainsKey(sets.Item2[i].Room) ? roomAliasses[sets.Item2[i].Room] : "")@(roomAliasses.ContainsKey(sets.Item2[i].Room) ? roomAliasses[sets.Item2[i].Room] : "") @@ -88,7 +88,7 @@ [Parameter, SupplyParameterFromQuery(Name = "b")] public string ImportSetBSpaceId { get; set; } = ""; - Dictionary> roomMembers { get; set; } = new(); + Dictionary> roomMembers { get; set; } = new(); Dictionary, List)> matches { get; set; } = new(); @@ -127,7 +127,7 @@ var setBusers = new Dictionary>(); await Task.WhenAll(GetMembers(RoomsA, setAusers), GetMembers(RoomsB, setBusers)); - + Log.Add($"Got {setAusers.Count} users in set A"); Log.Add($"Got {setBusers.Count} users in set B"); Log.Add("Calculating intersections..."); @@ -191,7 +191,7 @@ public class Match { public GenericRoom Room { get; set; } - public StateEventResponse Member { get; set; } + public MatrixEventResponse Member { get; set; } } } \ No newline at end of file diff --git a/MatrixUtils.Web/Pages/Tools/Moderation/UserTrace.razor b/MatrixUtils.Web/Pages/Tools/Moderation/UserTrace.razor index 2261cb8..d160922 100644 --- a/MatrixUtils.Web/Pages/Tools/Moderation/UserTrace.razor +++ b/MatrixUtils.Web/Pages/Tools/Moderation/UserTrace.razor @@ -139,7 +139,7 @@ private class Match { public GenericRoom Room; - public StateEventResponse Event; + public MatrixEventResponse Event; public string RoomName { get; set; } } @@ -169,7 +169,7 @@ } } - public string SummarizeMembership(StateEventResponse state) { + public string SummarizeMembership(MatrixEventResponse state) { var membership = state.ContentAs(); var time = DateTimeOffset.FromUnixTimeMilliseconds(state.OriginServerTs!.Value); return membership switch { -- cgit 1.5.1