@page "/PolicyListEditor/{RoomId}"
@using MatrixRoomUtils.Core.Extensions
@using MatrixRoomUtils.Core.StateEventTypes
@using System.Text.Json
@inject ILocalStorageService LocalStorage
@inject NavigationManager NavigationManager
Policy list editor - Editing @RoomId
This policy list contains @PolicyEvents.Count(x => x.Type == "m.policy.rule.server") server bans,
@PolicyEvents.Count(x => x.Type == "m.policy.rule.room") room bans and
@PolicyEvents.Count(x => x.Type == "m.policy.rule.user") user bans.
@if (!PolicyEvents.Any(x => x.Type == "m.policy.rule.server")) {
No server policies
}
else {
Server policies
Server |
Reason |
Expires |
Actions |
@foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.server" && x.Content.Entity != null)) {
Entity: @policyEvent.Content.Entity State: @policyEvent.StateKey |
@policyEvent.Content.Reason |
@policyEvent.Content.ExpiryDateTime
|
@* *@
|
}
Invalid events
State key |
Serialised Contents |
@foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.server" && x.Content.Entity == null)) {
@policyEvent.StateKey |
@policyEvent.Content.ToJson(false, true) |
}
}
@if (!PolicyEvents.Any(x => x.Type == "m.policy.rule.room")) {
No room policies
}
else {
Room policies
Room |
Reason |
Expires |
Actions |
@foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.room" && x.Content.Entity != null)) {
Entity: @policyEvent.Content.Entity State: @policyEvent.StateKey |
@policyEvent.Content.Reason |
@policyEvent.Content.ExpiryDateTime
|
|
}
Invalid events
State key |
Serialised Contents |
@foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.room" && x.Content.Entity == null)) {
@policyEvent.StateKey |
@policyEvent.Content.ToJson(false, true) |
}
}
@if (!PolicyEvents.Any(x => x.Type == "m.policy.rule.user")) {
No user policies
}
else {
User policies
@if (_enableAvatars) {
|
}
User |
Reason |
Expires |
Actions |
@foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.user" && x.Content.Entity != null)) {
@if (_enableAvatars) {
|
}
Entity: @string.Join("", policyEvent.Content.Entity.Take(64)) State: @string.Join("", policyEvent.StateKey.Take(64)) |
@policyEvent.Content.Reason |
@policyEvent.Content.ExpiryDateTime
|
|
}
Invalid events
State key |
Serialised Contents |
@foreach (var policyEvent in PolicyEvents.Where(x => x.Type == "m.policy.rule.user" && x.Content.Entity == null)) {
@policyEvent.StateKey |
@policyEvent.Content.ToJson(false, true) |
}
}
@code {
//get room list
// - sync withroom list filter
// Type = support.feline.msc3784
//support.feline.policy.lists.msc.v1
[Parameter]
public string? RoomId { get; set; }
private bool _enableAvatars;
static readonly Dictionary avatars = new();
static readonly Dictionary servers = new();
public static List> PolicyEvents { get; set; } = new();
protected override async Task OnInitializedAsync() {
await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
await base.OnInitializedAsync();
// if(RuntimeCache.AccessToken == null || RuntimeCache.CurrentHomeserver == null)
if (RuntimeCache.CurrentHomeServer == null) {
NavigationManager.NavigateTo("/Login");
return;
}
RoomId = RoomId.Replace('~', '.');
await LoadStatesAsync();
Console.WriteLine("Policy list editor initialized!");
}
private async Task LoadStatesAsync() {
// using var client = new HttpClient();
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", LocalStorageWrapper.AccessToken);
// var response = await client.GetAsync($"{LocalStorageWrapper.CurrentHomeserver}/_matrix/client/r0/rooms/{RoomId}/state");
// var Content = await response.Content.ReadAsStringAsync();
// Console.WriteLine(JsonSerializer.Deserialize