diff --git a/MatrixUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs b/MatrixUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs
index 215ad14..5c0fdab 100644
--- a/MatrixUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs
+++ b/MatrixUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs
@@ -12,7 +12,7 @@ public class DefaultRoomCreationTemplate : IRoomCreationTemplate {
new() {
Name = "My new room",
RoomAliasName = "myroom",
- InitialState = new List<StateEvent> {
+ InitialState = new List<MatrixEvent> {
new() {
Type = "m.room.history_visibility",
TypedContent = new RoomHistoryVisibilityEventContent() {
diff --git a/MatrixUtils.Web/MatrixUtils.Web.csproj b/MatrixUtils.Web/MatrixUtils.Web.csproj
index f7ebb62..e800c92 100644
--- a/MatrixUtils.Web/MatrixUtils.Web.csproj
+++ b/MatrixUtils.Web/MatrixUtils.Web.csproj
@@ -41,12 +41,12 @@
<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0"/>
<PackageReference Include="Blazored.SessionStorage" Version="2.4.0"/>
- <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.0-rc.2.25502.107"/>
- <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.0-rc.2.25502.107" PrivateAssets="all"/>
- <PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="10.0.0-rc.2.25502.107"/>
- <PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="10.0.0-rc.2.25502.107"/>
- <PackageReference Include="SpawnDev.BlazorJS" Version="2.38.0"/>
- <PackageReference Include="SpawnDev.BlazorJS.WebWorkers" Version="2.21.0"/>
+ <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.0"/>
+ <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.0" PrivateAssets="all"/>
+ <PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="10.0.0"/>
+ <PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="10.0.0"/>
+ <PackageReference Include="SpawnDev.BlazorJS" Version="2.47.0"/>
+ <PackageReference Include="SpawnDev.BlazorJS.WebWorkers" Version="2.26.0"/>
</ItemGroup>
<ItemGroup>
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<StateEventResponse>(EventJson);
+ Event = JsonSerializer.Deserialize<MatrixEventResponse>(EventJson);
MxcUrl = Event?.ContentAs<RoomMessageEventContent>()?.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<StateEventResponse?> TryGetTombstoneAsync() {
+ private async Task<MatrixEventResponse?> 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) {
<p>Rejoining room, please wait...</p>
<p>Members left to restore: </p>
@@ -82,7 +81,7 @@
private Exception? Error { get; set; }
// Stage 1
- private List<StateEventResponse>? Members { get; set; }
+ private List<MatrixEventResponse>? 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<StateEvent> AccountData { get; set; } = new();
+ public ObservableCollection<MatrixEvent> AccountData { get; set; } = new();
public ObservableCollection<RoomInfo> 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 @@
@* <pre Contenteditable="true" @onkeypress="@JsonChanged" content="JsonString">@JsonString</pre> *@
<style>
- table.table-top-first-tr tr td:first-child {
- vertical-align: top;
- }
- </style>
+ table.table-top-first-tr tr td:first-child {
+ vertical-align: top;
+ }
+</style>
<table class="table-top-first-tr">
<tr style="padding-bottom: 16px;">
<td>Preset:</td>
@@ -41,7 +41,10 @@
}
else {
<FancyTextBox @bind-Value="@creationEvent.Name"></FancyTextBox>
- <p>(#<FancyTextBox @bind-Value="@creationEvent.RoomAliasName"></FancyTextBox>:@Homeserver.WhoAmI.UserId.Split(':').Last())</p>
+ <p>(#
+ <FancyTextBox @bind-Value="@creationEvent.RoomAliasName"></FancyTextBox>
+ :@Homeserver.WhoAmI.UserId.Split(':').Last())
+ </p>
}
</td>
</tr>
@@ -89,7 +92,8 @@
<td>
@* <img src="@Homeserver.ResolveMediaUri(roomAvatarEvent.Url)" style="width: 128px; height: 128px; border-radius: 50%;"/> *@
<div style="display: inline-block; vertical-align: middle;">
- <FancyTextBox @bind-Value="@roomAvatarEvent.Url"></FancyTextBox><br/>
+ <FancyTextBox @bind-Value="@roomAvatarEvent.Url"></FancyTextBox>
+ <br/>
<InputFile OnChange="RoomIconFilePicked"></InputFile>
</div>
</td>
@@ -105,19 +109,27 @@
<FancyTextBox Formatter="@GetPermissionFriendlyName"
Value="@_event"
ValueChanged="val => { creationEvent.PowerLevelContentOverride.Events.ChangeKey(_event, val); }">
- </FancyTextBox>:
+ </FancyTextBox>
+ :
</td>
<td>
- <input type="number" value="@creationEvent.PowerLevelContentOverride.Events[_event]" @oninput="val => { creationEvent.PowerLevelContentOverride.Events[_event] = int.Parse(val.Value.ToString()); }" @onfocusout="() => { creationEvent.PowerLevelContentOverride.Events = creationEvent.PowerLevelContentOverride.Events.OrderByDescending(x => x.Value).ThenBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); }"/>
+ <input type="number" value="@creationEvent.PowerLevelContentOverride.Events[_event]"
+ @oninput="val => { creationEvent.PowerLevelContentOverride.Events[_event] = int.Parse(val.Value.ToString()); }"
+ @onfocusout="() => { creationEvent.PowerLevelContentOverride.Events = creationEvent.PowerLevelContentOverride.Events.OrderByDescending(x => x.Value).ThenBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); }"/>
</td>
</tr>
}
@foreach (var user in creationEvent.PowerLevelContentOverride.Users.Keys) {
var _user = user;
<tr>
- <td><FancyTextBox Value="@_user" ValueChanged="val => { creationEvent.PowerLevelContentOverride.Users.ChangeKey(_user, val); creationEvent.PowerLevelContentOverride.Users = creationEvent.PowerLevelContentOverride.Users.OrderByDescending(x => x.Value).ThenBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); }"></FancyTextBox>:</td>
<td>
- <input type="number" value="@creationEvent.PowerLevelContentOverride.Users[_user]" @oninput="val => { creationEvent.PowerLevelContentOverride.Users[_user] = int.Parse(val.Value.ToString()); }"/>
+ <FancyTextBox Value="@_user"
+ ValueChanged="val => { creationEvent.PowerLevelContentOverride.Users.ChangeKey(_user, val); creationEvent.PowerLevelContentOverride.Users = creationEvent.PowerLevelContentOverride.Users.OrderByDescending(x => x.Value).ThenBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); }"></FancyTextBox>
+ :
+ </td>
+ <td>
+ <input type="number" value="@creationEvent.PowerLevelContentOverride.Users[_user]"
+ @oninput="val => { creationEvent.PowerLevelContentOverride.Users[_user] = int.Parse(val.Value.ToString()); }"/>
</td>
</tr>
}
@@ -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<Type, List<StateEventResponse>> PolicyEventsByType { get; set; } = new();
+ private Dictionary<Type, List<MatrixEventResponse>> 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<StateEventResponse, int> ActiveKicks { get; set; } = [];
+ public Dictionary<MatrixEventResponse, int> ActiveKicks { get; set; } = [];
- private static FrozenSet<Type> KnownPolicyTypes = StateEvent.KnownStateEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet();
+ private static FrozenSet<Type> KnownPolicyTypes = MatrixEvent.KnownEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet();
// event types, unnamed
// private static Dictionary<string, Type> PolicyTypes = KnownPolicyTypes
@@ -274,14 +274,14 @@ else {
if (evt.RawContent is null or { Count: 0 } || string.IsNullOrWhiteSpace(evt.RawContent?["recommendation"]?.GetValue<string>())) {
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<StateEventResponse>(), (acc, val) => {
+ .Aggregate(new List<MatrixEventResponse>(), (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<List<PolicyCollection.PolicyInfo>> CheckDuplicatePoliciesAsync(SpawnDev.BlazorJS.JSObjects.String policiesJson, int start, int end) {
- var policies = JsonSerializer.Deserialize<List<StateEventResponse>>(policiesJson.ValueOf());
+ var policies = JsonSerializer.Deserialize<List<MatrixEventResponse>>(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<List<PolicyCollection.PolicyInfo>> CheckDuplicatePoliciesAsync(string policiesJson, int start, int end) {
- var policies = JsonSerializer.Deserialize<List<StateEventResponse>>(policiesJson);
+ var policies = JsonSerializer.Deserialize<List<MatrixEventResponse>>(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<List<PolicyCollection.PolicyInfo>> CheckDuplicatePoliciesAsync(List<StateEventResponse> policies, int start, int end)
+ private static Task<List<PolicyCollection.PolicyInfo>> CheckDuplicatePoliciesAsync(List<MatrixEventResponse> policies, int start, int end)
=> CheckDuplicatePoliciesAsync(policies, start .. end);
[return: WorkerTransfer]
- private static async Task<List<PolicyCollection.PolicyInfo>> CheckDuplicatePoliciesAsync(List<StateEventResponse> policies, Range range) {
+ private static async Task<List<PolicyCollection.PolicyInfo>> CheckDuplicatePoliciesAsync(List<MatrixEventResponse> policies, Range range) {
var sw = Stopwatch.StartNew();
var jsConsole = App.Host.Services.GetService<JsConsoleService>()!;
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<PolicyCollection.PolicyInfo>();
foreach (var (policyEvent, policyContent) in toCheck) {
- List<StateEventResponse> duplicatedBy = [];
- List<StateEventResponse> madeRedundantBy = [];
+ List<MatrixEventResponse> duplicatedBy = [];
+ List<MatrixEventResponse> 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
- <StateEventResponse>(16000));
+ <MatrixEventResponse>(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<StateEventResponse> GetPolicyEventsByType(Type type) => PolicyEventsByType.ContainsKey(type) ? PolicyEventsByType[type] : [];
+ private List<MatrixEventResponse> GetPolicyEventsByType(Type type) => PolicyEventsByType.ContainsKey(type) ? PolicyEventsByType[type] : [];
- // private List<StateEventResponse> GetValidPolicyEventsByType(Type type) => GetPolicyEventsByType(type)
+ // private List<MatrixEventResponse> GetValidPolicyEventsByType(Type type) => GetPolicyEventsByType(type)
// .Where(x => !string.IsNullOrWhiteSpace(x.RawContent?["recommendation"]?.GetValue<string>())).ToList();
//
- // private List<StateEventResponse> GetInvalidPolicyEventsByType(Type type) => GetPolicyEventsByType(type)
+ // private List<MatrixEventResponse> GetInvalidPolicyEventsByType(Type type) => GetPolicyEventsByType(type)
// .Where(x => x.RawContent is { Count: > 0 } && string.IsNullOrWhiteSpace(x.RawContent?["recommendation"]?.GetValue<string>())).ToList();
//
- // private List<StateEventResponse> GetRemovedPolicyEventsByType(Type type) => GetPolicyEventsByType(type)
+ // private List<MatrixEventResponse> 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<string, PropertyInfo> PropertiesToDisplay { get; set; }
public class PolicyInfo {
- public required StateEventResponse Policy { get; init; }
- public required List<StateEventResponse> MadeRedundantBy { get; set; }
- public required List<StateEventResponse> DuplicatedBy { get; set; }
+ public required MatrixEventResponse Policy { get; init; }
+ public required List<MatrixEventResponse> MadeRedundantBy { get; set; }
+ public required List<MatrixEventResponse> 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<string> roomIds) {
+ public static async Task ExecuteKickWithWasmWorkers(WebWorkerService workerService, AuthenticatedHomeserverGeneric hs, MatrixEventResponse evt, List<string> 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 @@
<h3>Policy list editor - Editing @RoomId</h3>
<hr/>
@* <InputCheckbox @bind-Value="EnableAvatars"></InputCheckbox><label>Enable avatars (WILL EXPOSE YOUR IP TO TARGET HOMESERVERS!)</label> *@
-<LinkButton OnClickAsync="@(() => { CurrentlyEditingEvent = new() { Type = "", RawContent = new() }; return Task.CompletedTask; })">Create new policy</LinkButton>
+<LinkButton OnClickAsync="@(() => {
+ CurrentlyEditingEvent = new() { Type = "", RawContent = new() };
+ return Task.CompletedTask;
+ })">Create new policy
+</LinkButton>
@if (Loading) {
<p>Loading...</p>
@@ -71,14 +75,22 @@ else {
}
<div style="display: ruby;">
@if (PowerLevels.UserHasStatePermission(Homeserver.WhoAmI.UserId, policy.Type)) {
- <LinkButton OnClickAsync="@(() => { CurrentlyEditingEvent = policy; return Task.CompletedTask; })">Edit</LinkButton>
+ <LinkButton OnClickAsync="@(() => {
+ CurrentlyEditingEvent = policy;
+ return Task.CompletedTask;
+ })">Edit
+ </LinkButton>
<LinkButton OnClickAsync="@(() => RemovePolicyAsync(policy))">Remove</LinkButton>
@if (policy.IsLegacyType) {
<LinkButton OnClickAsync="@(() => RemovePolicyAsync(policy))">Update policy type</LinkButton>
}
@if (PolicyTypeIds[typeof(ServerPolicyRuleEventContent)].Contains(policy.EventId)) {
- <LinkButton OnClickAsync="@(() => { ServerPolicyToMakePermanent = policy; return Task.CompletedTask; })">Make permanent (wildcard)</LinkButton>
+ <LinkButton OnClickAsync="@(() => {
+ ServerPolicyToMakePermanent = policy;
+ return Task.CompletedTask;
+ })">Make permanent (wildcard)
+ </LinkButton>
@if (CurrentUserIsDraupnir) {
<LinkButton OnClickAsync="@(() => UpgradePolicyAsync(policy))">Kick matching users</LinkButton>
}
@@ -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<Type, List<StateEventResponse>> PolicyEventsByType { get; set; } = new();
+ private Dictionary<Type, List<MatrixEventResponse>> 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<StateEventResponse> GetPolicyEventsByType(Type type) => PolicyEventsByType.ContainsKey(type) ? PolicyEventsByType[type] : [];
+ private List<MatrixEventResponse> GetPolicyEventsByType(Type type) => PolicyEventsByType.ContainsKey(type) ? PolicyEventsByType[type] : [];
- private List<StateEventResponse> GetValidPolicyEventsByType(Type type) => GetPolicyEventsByType(type)
+ private List<MatrixEventResponse> GetValidPolicyEventsByType(Type type) => GetPolicyEventsByType(type)
.Where(x => !string.IsNullOrWhiteSpace(x.RawContent?["recommendation"]?.GetValue<string>())).ToList();
- private List<StateEventResponse> GetInvalidPolicyEventsByType(Type type) => GetPolicyEventsByType(type)
+ private List<MatrixEventResponse> GetInvalidPolicyEventsByType(Type type) => GetPolicyEventsByType(type)
.Where(x => string.IsNullOrWhiteSpace(x.RawContent?["recommendation"]?.GetValue<string>())).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<Type> KnownPolicyTypes = StateEvent.KnownStateEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet();
+ private static FrozenSet<Type> KnownPolicyTypes = MatrixEvent.KnownEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet();
// event types, unnamed
private static Dictionary<string, Type> 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<RoomInfo> FromRoom(GenericRoom room, List<StateEventResponse>? state = null, bool legacy = false) {
+ public static async Task<RoomInfo> FromRoom(GenericRoom room, List<MatrixEventResponse>? 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 @@
<tr>
<td style="vertical-align: top;">Initial room state:</td>
<td>
- @foreach (var (displayName, events) in new Dictionary<string, List<StateEvent>>() {
+ @foreach (var (displayName, events) in new Dictionary<string, List<MatrixEvent>>() {
{ "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<StateEvent>(json)); *@
+ @* events.Replace(initialState, JsonSerializer.Deserialize<MatrixEvent>(json)); *@
@* StateHasChanged(); *@
@* })"></FancyTextBox> *@
- <FancyTextBoxLazyJson T="StateEvent" Value="@initialState" ValueChanged="@(evt => { events.Replace(initialState, evt); })"></FancyTextBoxLazyJson>
+ <FancyTextBoxLazyJson T="MatrixEvent" Value="@initialState" ValueChanged="@(evt => { events.Replace(initialState, evt); })"></FancyTextBoxLazyJson>
<br/>
</div>
}
@@ -71,7 +71,7 @@
[Parameter]
public AuthenticatedHomeserverGeneric Homeserver { get; set; }
- private RenderFragment GetRemoveButton(List<StateEvent> events, StateEvent initialState) {
+ private RenderFragment GetRemoveButton(List<MatrixEvent> events, MatrixEvent initialState) {
return @<span>
<LinkButton InlineText="true" OnClick="@(() => {
events.Remove(initialState);
diff --git a/MatrixUtils.Web/Pages/Rooms/Space.razor b/MatrixUtils.Web/Pages/Rooms/Space.razor
index fc9c9bf..93df5a9 100644
--- a/MatrixUtils.Web/Pages/Rooms/Space.razor
+++ b/MatrixUtils.Web/Pages/Rooms/Space.razor
@@ -30,7 +30,7 @@
private GenericRoom? Room { get; set; }
- private StateEventResponse[] States { get; set; } = Array.Empty<StateEventResponse>();
+ private MatrixEventResponse[] States { get; set; } = Array.Empty<MatrixEventResponse>();
private List<RoomInfo> Rooms { get; } = new();
private List<string> ServersInSpace { get; } = new();
private string? NewRoomId { get; set; }
@@ -61,6 +61,7 @@
}
});
}
+
break;
}
case "m.room.member": {
@@ -68,44 +69,46 @@
if (!ServersInSpace.Contains(serverName)) {
ServersInSpace.Add(serverName);
}
+
break;
}
}
}
+
await base.OnInitializedAsync();
- // var state = await Room.GetStateAsync("");
- // if (state is not null) {
- // // Console.WriteLine(state.Value.ToJson());
- // States = state.Value.Deserialize<StateEventResponse[]>()!;
- //
- // 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<MatrixEventResponse[]>()!;
+ //
+ // 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<StateEventResponse> FilteredEvents { get; set; } = new();
- public List<StateEventResponse> Events { get; set; } = new();
+ public List<MatrixEventResponse> FilteredEvents { get; set; } = new();
+ public List<MatrixEventResponse> 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 @@
<table class="table table-striped table-hover" style="width: fit-Content;">
<thead>
- <tr>
- <th scope="col">Type</th>
- <th scope="col">Content</th>
- </tr>
- </thead>
- <tbody>
- @foreach (var stateEvent in FilteredEvents.Where(x => x.StateKey == "").OrderBy(x => x.OriginServerTs)) {
<tr>
- <td>@stateEvent.Type</td>
- <td style="max-width: fit-Content;">
- <pre>@stateEvent.RawContent.ToJson()</pre>
- </td>
+ <th scope="col">Type</th>
+ <th scope="col">Content</th>
</tr>
- }
+ </thead>
+ <tbody>
+ @foreach (var stateEvent in FilteredEvents.Where(x => x.StateKey == "").OrderBy(x => x.OriginServerTs)) {
+ <tr>
+ <td>@stateEvent.Type</td>
+ <td style="max-width: fit-Content;">
+ <pre>@stateEvent.RawContent.ToJson()</pre>
+ </td>
+ </tr>
+ }
</tbody>
</table>
@@ -34,20 +34,20 @@
<summary>@group.Key</summary>
<table class="table table-striped table-hover" style="width: fit-Content;">
<thead>
- <tr>
- <th scope="col">Type</th>
- <th scope="col">Content</th>
- </tr>
- </thead>
- <tbody>
- @foreach (var stateEvent in group.OrderBy(x => x.OriginServerTs)) {
<tr>
- <td>@stateEvent.Type</td>
- <td style="max-width: fit-Content;">
- <pre>@stateEvent.RawContent.ToJson()</pre>
- </td>
+ <th scope="col">Type</th>
+ <th scope="col">Content</th>
</tr>
- }
+ </thead>
+ <tbody>
+ @foreach (var stateEvent in group.OrderBy(x => x.OriginServerTs)) {
+ <tr>
+ <td>@stateEvent.Type</td>
+ <td style="max-width: fit-Content;">
+ <pre>@stateEvent.RawContent.ToJson()</pre>
+ </td>
+ </tr>
+ }
</tbody>
</table>
</details>
@@ -64,8 +64,8 @@
[Parameter]
public string? RoomId { get; set; }
- public List<StateEventResponse> FilteredEvents { get; set; } = new();
- public List<StateEventResponse> Events { get; set; } = new();
+ public List<MatrixEventResponse> FilteredEvents { get; set; } = new();
+ public List<MatrixEventResponse> 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<TimelineEventItem> Events { get; } = new();
- private List<StateEventResponse> RawEvents { get; } = new();
+ private List<MatrixEventResponse> 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<MatrixEventAttribute>().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<string> log { get; set; } = new();
List<AuthenticatedHomeserverGeneric> hss { get; set; } = new();
ObservableCollection<GenericRoom> rooms { get; set; } = new();
- Dictionary<GenericRoom, FrozenSet<StateEventResponse>> roomMembers { get; set; } = new();
+ Dictionary<GenericRoom, FrozenSet<MatrixEventResponse>> roomMembers { get; set; } = new();
Dictionary<string, List<Matches>> 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 @@
</p>
<p>
<LinkButton OnClickAsync="@(async () => {
- ShowJoins = ShowLeaves = ShowKnocks = ShowInvites = ShowBans = false;
- StateHasChanged();
- })">Hide all
+ ShowJoins = ShowLeaves = ShowKnocks = ShowInvites = ShowBans = false;
+ StateHasChanged();
+ })">Hide all
</LinkButton>
<LinkButton OnClickAsync="@(async () => {
- ShowJoins = ShowLeaves = ShowKnocks = ShowInvites = ShowBans = true;
- StateHasChanged();
- })">Show all
+ ShowJoins = ShowLeaves = ShowKnocks = ShowInvites = ShowBans = true;
+ StateHasChanged();
+ })">Show all
</LinkButton>
<LinkButton OnClickAsync="@(async () => {
- ShowJoins ^= true;
- ShowLeaves ^= true;
- ShowKnocks ^= true;
- ShowInvites ^= true;
- ShowBans ^= true;
- StateHasChanged();
- })">Toggle all
+ ShowJoins ^= true;
+ ShowLeaves ^= true;
+ ShowKnocks ^= true;
+ ShowInvites ^= true;
+ ShowBans ^= true;
+ StateHasChanged();
+ })">Toggle all
</LinkButton>
</p>
<p>
@@ -56,25 +56,25 @@
<span><InputCheckbox @bind-Value="DisambiguateKicks"/> kicks</span>
<span><InputCheckbox @bind-Value="DisambiguateUnbans"/> unbans</span>
<span><InputCheckbox @bind-Value="DisambiguateProfileUpdates"/> profile updates</span>
- <details style="display: inline-block; vertical-align: top;">
- <summary>
- <InputCheckbox @bind-Value="DisambiguateInviteActions"/>
- invite actions
- </summary>
- <span><InputCheckbox @bind-Value="DisambiguateInviteAccepted"/> accepted</span>
- <span><InputCheckbox @bind-Value="DisambiguateInviteRejected"/> rejected</span>
- <span><InputCheckbox @bind-Value="DisambiguateInviteRetracted"/> retracted</span>
- </details>
- <details style="display: inline-block; vertical-align: top;">
- <summary>
- <InputCheckbox @bind-Value="DisambiguateKnockActions"/>
- knock actions
- </summary>
- <span><InputCheckbox @bind-Value="DisambiguateKnockAccepted"/> accepted</span>
- <span><InputCheckbox @bind-Value="DisambiguateKnockRejected"/> rejected</span>
- <span><InputCheckbox @bind-Value="DisambiguateKnockRetracted"/> retracted</span>
- </details>
- }
+ <details style="display: inline-block; vertical-align: top;">
+ <summary>
+ <InputCheckbox @bind-Value="DisambiguateInviteActions"/>
+ invite actions
+ </summary>
+ <span><InputCheckbox @bind-Value="DisambiguateInviteAccepted"/> accepted</span>
+ <span><InputCheckbox @bind-Value="DisambiguateInviteRejected"/> rejected</span>
+ <span><InputCheckbox @bind-Value="DisambiguateInviteRetracted"/> retracted</span>
+ </details>
+ <details style="display: inline-block; vertical-align: top;">
+ <summary>
+ <InputCheckbox @bind-Value="DisambiguateKnockActions"/>
+ knock actions
+ </summary>
+ <span><InputCheckbox @bind-Value="DisambiguateKnockAccepted"/> accepted</span>
+ <span><InputCheckbox @bind-Value="DisambiguateKnockRejected"/> rejected</span>
+ <span><InputCheckbox @bind-Value="DisambiguateKnockRetracted"/> retracted</span>
+ </details>
+}
</p>
@if (DoDisambiguate) {
<p>
@@ -130,29 +130,29 @@
<p>
<LinkButton OnClickAsync="@(async () => {
- DoDisambiguate = DisambiguateProfileUpdates = DisambiguateKicks = DisambiguateUnbans = DisambiguateInviteAccepted = DisambiguateInviteRejected = DisambiguateInviteRetracted = DisambiguateKnockAccepted = DisambiguateKnockRejected = DisambiguateKnockRetracted = DisambiguateKnockActions = DisambiguateInviteActions = false;
- StateHasChanged();
- })">Un-disambiguate all
+ DoDisambiguate = DisambiguateProfileUpdates = DisambiguateKicks = DisambiguateUnbans = DisambiguateInviteAccepted = DisambiguateInviteRejected = DisambiguateInviteRetracted = DisambiguateKnockAccepted = DisambiguateKnockRejected = DisambiguateKnockRetracted = DisambiguateKnockActions = DisambiguateInviteActions = false;
+ StateHasChanged();
+ })">Un-disambiguate all
</LinkButton>
<LinkButton OnClickAsync="@(async () => {
- DoDisambiguate = DisambiguateProfileUpdates = DisambiguateKicks = DisambiguateUnbans = DisambiguateInviteAccepted = DisambiguateInviteRejected = DisambiguateInviteRetracted = DisambiguateKnockAccepted = DisambiguateKnockRejected = DisambiguateKnockRetracted = DisambiguateKnockActions = DisambiguateInviteActions = true;
- StateHasChanged();
- })">Disambiguate all
+ DoDisambiguate = DisambiguateProfileUpdates = DisambiguateKicks = DisambiguateUnbans = DisambiguateInviteAccepted = DisambiguateInviteRejected = DisambiguateInviteRetracted = DisambiguateKnockAccepted = DisambiguateKnockRejected = DisambiguateKnockRetracted = DisambiguateKnockActions = DisambiguateInviteActions = true;
+ StateHasChanged();
+ })">Disambiguate all
</LinkButton>
<LinkButton OnClickAsync="@(async () => {
- 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
+ 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
</LinkButton>
</p>
}
@@ -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<string> Log { get; set; } = new();
- private List<StateEventResponse> Memberships { get; set; } = [];
+ private List<MatrixEventResponse> 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<MembershipEntry> GetTransitions(List<StateEventResponse> evts) {
+ private static IEnumerable<MembershipEntry> GetTransitions(List<MatrixEventResponse> evts) {
Dictionary<string, MembershipEntry> 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 @@
<td>@sets.Item2[0].Room.RoomId</td>
<td>@((sets.Item2[i].Member.TypedContent as RoomMemberEventContent).Membership)</td>
<td>@(roomNames.ContainsKey(sets.Item2[i].Room) ? roomNames[sets.Item2[i].Room] : "")</td>
- <td>@(roomAliasses.ContainsKey(sets.Item2[i].Room) ? roomAliasses[sets.Item2[i].Room] : "")</td>
+ <td>@(roomAliasses.ContainsKey(sets.Item2[i].Room) ? roomAliasses[sets.Item2[i].Room] : "")</td>
}
else {
<td/>
@@ -88,7 +88,7 @@
[Parameter, SupplyParameterFromQuery(Name = "b")]
public string ImportSetBSpaceId { get; set; } = "";
- Dictionary<string, Dictionary<GenericRoom, StateEventResponse>> roomMembers { get; set; } = new();
+ Dictionary<string, Dictionary<GenericRoom, MatrixEventResponse>> roomMembers { get; set; } = new();
Dictionary<string, (List<Match>, List<Match>)> matches { get; set; } = new();
@@ -127,7 +127,7 @@
var setBusers = new Dictionary<string, List<Match>>();
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<RoomMemberEventContent>();
var time = DateTimeOffset.FromUnixTimeMilliseconds(state.OriginServerTs!.Value);
return membership switch {
diff --git a/MatrixUtils.Web/Program.cs b/MatrixUtils.Web/Program.cs
index e48782f..58b66c1 100644
--- a/MatrixUtils.Web/Program.cs
+++ b/MatrixUtils.Web/Program.cs
@@ -29,7 +29,7 @@ builder.Services.AddWebWorkerService(webWorkerService => {
webWorkerService.TaskPool.MaxPoolSize = -1;
// Below is telling the WebWorkerService TaskPool to set the initial size to 2 if running in a Window scope and 0 otherwise
// This starts up 2 WebWorkers to handle TaskPool tasks as needed
- webWorkerService.TaskPool.PoolSize = webWorkerService.GlobalScope == GlobalScope.Window ? 0 : 0;
+ // webWorkerService.TaskPool.PoolSize = webWorkerService.GlobalScope == GlobalScope.Window ? 0 : 0;
});
try {
diff --git a/MatrixUtils.Web/Shared/PolicyEditorComponents/MassPolicyEditorModal.razor b/MatrixUtils.Web/Shared/PolicyEditorComponents/MassPolicyEditorModal.razor
index bb4b672..b49358d 100644
--- a/MatrixUtils.Web/Shared/PolicyEditorComponents/MassPolicyEditorModal.razor
+++ b/MatrixUtils.Web/Shared/PolicyEditorComponents/MassPolicyEditorModal.razor
@@ -96,7 +96,7 @@
private bool VerifyIntent { get; set; }
- private static FrozenSet<Type> KnownPolicyTypes = StateEvent.KnownStateEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet();
+ private static FrozenSet<Type> KnownPolicyTypes = MatrixEvent.KnownEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet();
private static Dictionary<string, Type> PolicyTypes = KnownPolicyTypes
.ToDictionary(x => x.GetCustomAttributes<MatrixEventAttribute>().First(y => !string.IsNullOrWhiteSpace(y.EventName)).EventName, x => x);
@@ -177,20 +177,20 @@
// var tasks = entities.Select(x => ExecuteBan(Room, x)).ToList();
// await Task.WhenAll(tasks);
-
+
var events = entities.Select(entity => {
var content = Activator.CreateInstance(PolicyTypes[MappedType!]) as PolicyRuleEventContent ?? throw new InvalidOperationException("Failed to create event content");
content.Recommendation = Recommendation;
content.Reason = Reason;
content.Entity = entity;
- return new StateEvent() {
+ return new MatrixEvent() {
Type = MappedType,
TypedContent = content,
StateKey = content.GetDraupnir2StateKey()
};
});
-
- foreach(var chunk in events.Chunk(50))
+
+ foreach (var chunk in events.Chunk(50))
await Room.BulkSendEventsAsync(chunk);
OnSaved.Invoke();
diff --git a/MatrixUtils.Web/Shared/PolicyEditorComponents/PolicyEditorModal.razor b/MatrixUtils.Web/Shared/PolicyEditorComponents/PolicyEditorModal.razor
index 0205e16..501ca99 100644
--- a/MatrixUtils.Web/Shared/PolicyEditorComponents/PolicyEditorModal.razor
+++ b/MatrixUtils.Web/Shared/PolicyEditorComponents/PolicyEditorModal.razor
@@ -113,7 +113,7 @@
@code {
[Parameter]
- public StateEventResponse? PolicyEvent {
+ public MatrixEventResponse? PolicyEvent {
get => _policyEvent;
set {
if (value is not null && value != _policyEvent)
@@ -139,10 +139,10 @@
}
[Parameter]
- public Action<StateEventResponse>? OnSave { get; set; }
+ public Action<MatrixEventResponse>? OnSave { get; set; }
[Parameter]
- public Func<StateEventResponse, Task>? OnSaveAsync { get; set; }
+ public Func<MatrixEventResponse, Task>? OnSaveAsync { get; set; }
private async Task InvokeOnSave() {
if (OnSave is not null)
@@ -154,12 +154,12 @@
public PolicyRuleEventContent? PolicyData { get; set; }
- private static FrozenSet<Type> KnownPolicyTypes = StateEvent.KnownStateEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet();
+ private static FrozenSet<Type> KnownPolicyTypes = MatrixEvent.KnownEventTypes.Where(x => x.IsAssignableTo(typeof(PolicyRuleEventContent))).ToFrozenSet();
private static Dictionary<string, Type> PolicyTypes = KnownPolicyTypes
.ToDictionary(x => x.GetCustomAttributes<MatrixEventAttribute>().First(y => !string.IsNullOrWhiteSpace(y.EventName)).EventName, x => x);
- private StateEventResponse? _policyEvent;
+ private MatrixEventResponse? _policyEvent;
private string? MappedType {
get => _policyEvent?.Type;
diff --git a/MatrixUtils.Web/Shared/TimelineComponents/BaseTimelineItem.razor b/MatrixUtils.Web/Shared/TimelineComponents/BaseTimelineItem.razor
index f107eb3..80c69f2 100644
--- a/MatrixUtils.Web/Shared/TimelineComponents/BaseTimelineItem.razor
+++ b/MatrixUtils.Web/Shared/TimelineComponents/BaseTimelineItem.razor
@@ -6,19 +6,19 @@
@code {
[Parameter]
- public StateEventResponse Event { get; set; }
+ public MatrixEventResponse Event { get; set; }
[Parameter]
- public List<StateEventResponse> Events { get; set; }
+ public List<MatrixEventResponse> Events { get; set; }
[Parameter]
public AuthenticatedHomeserverGeneric Homeserver { get; set; }
- public IEnumerable<StateEventResponse> EventsBefore => Events.TakeWhile(e => e.EventId != Event.EventId);
+ public IEnumerable<MatrixEventResponse> EventsBefore => Events.TakeWhile(e => e.EventId != Event.EventId);
- public IEnumerable<StateEventResponse> MatchingEventsBefore => EventsBefore.Where(x => x.Type == Event.Type && x.StateKey == Event.StateKey);
+ public IEnumerable<MatrixEventResponse> MatchingEventsBefore => EventsBefore.Where(x => x.Type == Event.Type && x.StateKey == Event.StateKey);
- public StateEventResponse? PreviousState => MatchingEventsBefore.LastOrDefault();
+ public MatrixEventResponse? PreviousState => MatchingEventsBefore.LastOrDefault();
public RoomMemberEventContent? CurrentSenderMemberEventContent => EventsBefore.LastOrDefault(x => x.Type == "m.room.member" && x.StateKey == Event.Sender)?
.TypedContent as RoomMemberEventContent;
@@ -27,6 +27,4 @@
public bool HasPreviousMessage => EventsBefore.Last() is { Type: "m.room.message" } response && response.Sender == Event.Sender;
-
-
}
\ No newline at end of file
diff --git a/MatrixUtils.Web/wwwroot/index.html b/MatrixUtils.Web/wwwroot/index.html
index 0a80cff..3334426 100644
--- a/MatrixUtils.Web/wwwroot/index.html
+++ b/MatrixUtils.Web/wwwroot/index.html
@@ -3,31 +3,32 @@
<head>
<meta charset="utf-8"/>
- <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>MatrixUtils.Web</title>
<base href="/"/>
- <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet"/>
- <link href="css/app.css" rel="stylesheet"/>
+ <link rel="preload" id="webassembly"/>
+ <link rel="stylesheet" href="css/bootstrap/bootstrap.min.css"/>
+ <link rel="stylesheet" href="css/app.css"/>
+ <link rel="icon" type="image/png" href="favicon.png"/>
+ <link href="MatrixUtils.Web.styles.css" rel="stylesheet"/>
<link rel="manifest" href="rmu.webmanifest"/>
<link rel="apple-touch-icon" sizes="512x512" href="icon-512.png"/>
- <link href="favicon.png" rel="icon" type="image/png"/>
- <link href="MatrixUtils.Web.styles.css" rel="stylesheet"/>
- <link rel="preload" id="webassembly"/>
+ <link rel="apple-touch-icon" sizes="192x192" href="icon-192.png"/>
</head>
<body>
<div id="app">
<svg class="loading-progress">
- <circle cx="50%" cy="50%" r="40%"/>
- <circle cx="50%" cy="50%" r="40%"/>
+ <circle r="40%" cx="50%" cy="50%"/>
+ <circle r="40%" cx="50%" cy="50%"/>
</svg>
<div class="loading-progress-text"></div>
</div>
<div id="blazor-error-ui">
An unhandled error has occurred.
- <a class="reload" href="">Reload</a>
- <a class="dismiss">🗙</a>
+ <a href="." class="reload">Reload</a>
+ <span class="dismiss">🗙</span>
</div>
<script>
function getWidth(element) {
@@ -65,7 +66,7 @@
image.src = url;
}
</script>
- <script src="_framework/blazor.webassembly.js"></script>
+ <script src="_framework/blazor.webassembly#[.{fingerprint}].js"></script>
<!-- <script>navigator.serviceWorker.register('service-worker.js');</script>-->
<script src="sw-registrator.js"></script>
</body>
diff --git a/MatrixUtils.Web/wwwroot/service-worker.published.js b/MatrixUtils.Web/wwwroot/service-worker.published.js
index 9219755..aafb48c 100644
--- a/MatrixUtils.Web/wwwroot/service-worker.published.js
+++ b/MatrixUtils.Web/wwwroot/service-worker.published.js
@@ -9,7 +9,7 @@ self.addEventListener('fetch', event => event.respondWith(onFetch(event)));
const cacheNamePrefix = 'offline-cache-';
const cacheName = `${cacheNamePrefix}${self.assetsManifest.version}`;
const offlineAssetsInclude = [// Standard resources
- /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/, /* Extra known-static paths */
+ /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/, /\.webmanifest$/, /* Extra known-static paths */
/\/_matrix\/media\/.{2}\/download\//, /api\.dicebear\.com\/6\.x\/identicon\/svg/];
const offlineAssetsExclude = [/^service-worker\.js$/];
@@ -28,7 +28,7 @@ async function onInstall(event) {
const assetsRequests = self.assetsManifest.assets
.filter(asset => offlineAssetsInclude.some(pattern => pattern.test(asset.url)))
.filter(asset => !offlineAssetsExclude.some(pattern => pattern.test(asset.url)))
- .map(asset => new Request(asset.url, {integrity: asset.hash, cache: 'no-cache'}));
+ .map(asset => new Request(asset.url, {cache: 'no-cache'})); /* integrity: asset.hash */
await caches.open(cacheName).then(cache => cache.addAll(assetsRequests));
}
@@ -48,12 +48,26 @@ async function onFetch(event) {
// For all navigation requests, try to serve index.html from cache,
// unless that request is for an offline resource.
// If you need some URLs to be server-rendered, edit the following check to exclude those URLs
- const shouldServeIndexHtml = event.request.mode === 'navigate' && !manifestUrlList.some(url => url === event.request.url);
+ const shouldServeIndexHtml = event.request.mode === 'navigate'
+ && !manifestUrlList.some(url => url === event.request.url);
const request = shouldServeIndexHtml ? 'index.html' : event.request;
const shouldCache = offlineAssetsInclude.some(pattern => pattern.test(request.url));
const cache = await caches.open(cacheName);
+
+ if (request !== 'index.html' && request.url.endsWith("_framework/dotnet.js")) {
+ // return `_framework/dotnet.<hash>.js` from cache to avoid integrity errors
+ const dotnetJsUrl = manifestUrlList.find(url => /_framework\/dotnet\.[a-z0-9]+\.js$/.test(url));
+ if (dotnetJsUrl) {
+ cachedResponse = await cache.match(dotnetJsUrl);
+ if (cachedResponse) {
+ console.log("Service worker caching: serving dotnet.js from cache: ", dotnetJsUrl);
+ return cachedResponse;
+ }
+ } else console.warn("Service worker caching: could not find dotnet.hash.js in manifest", {request, manifestUrlList});
+ }
+
cachedResponse = await cache.match(request);
let exception;
let fetched;
@@ -72,7 +86,7 @@ async function onFetch(event) {
fetched, shouldCache, request, exception, cachedResponse, url: request.url,
}
Object.keys(consoleLog).forEach(key => consoleLog[key] == null && delete consoleLog[key])
- if(consoleLog.exception)
+ if (consoleLog.exception)
console.log("Service worker caching: ", consoleLog)
}
diff --git a/MatrixUtils.Web/wwwroot/sw-registrator.js b/MatrixUtils.Web/wwwroot/sw-registrator.js
index 67aa5cb..b57d26a 100644
--- a/MatrixUtils.Web/wwwroot/sw-registrator.js
+++ b/MatrixUtils.Web/wwwroot/sw-registrator.js
@@ -15,7 +15,7 @@ window.updateAvailable = new Promise((resolve, reject) => {
// detect updates every minute
setInterval(() => {
registration.update();
- }, 5 * 1000); // 60000ms -> check each minute
+ }, 30 * 1000); // 60000ms -> check each minute
registration.onupdatefound = () => {
const installingServiceWorker = registration.installing;
|