about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-05-30 19:07:09 +0000
committerRory& <root@rory.gay>2024-05-30 19:07:09 +0000
commitcf90f02e1f9c9f7d037976cace2b9c49119c741c (patch)
tree3925bd8d689c3f330c217b0f867ba8a241d893e7
parentRename legacy event types (diff)
downloadLibMatrix-cf90f02e1f9c9f7d037976cace2b9c49119c741c.tar.xz
Start implementing new event system
Diffstat (limited to '')
-rw-r--r--ConsoleApp1/ConsoleApp1.csproj14
-rw-r--r--ConsoleApp1/Program.cs25
m---------ExampleBots/ModerationBot0
-rw-r--r--LibMatrix.EventTypes/Events/RoomMembershipEventContent.cs10
-rw-r--r--LibMatrix.EventTypes/MatrixEvent.cs9
-rw-r--r--LibMatrix.EventTypes/MatrixEventCollection.cs71
-rw-r--r--LibMatrix.EventTypes/MatrixEventContent.cs26
-rw-r--r--LibMatrix.EventTypes/temp/Temp.cs17
-rw-r--r--LibMatrix.sln6
-rw-r--r--LibMatrix.sln.DotSettings.user6
-rw-r--r--LibMatrix/Extensions/EnumerableExtensions.cs2
-rw-r--r--LibMatrix/Filters/MatrixFilter.cs (renamed from LibMatrix/Filters/SyncFilter.cs)2
-rw-r--r--LibMatrix/Helpers/MessageBuilder.cs5
-rw-r--r--LibMatrix/Helpers/SyncHelper.cs4
-rw-r--r--LibMatrix/Helpers/SyncStateResolver.cs2
-rw-r--r--LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs12
-rw-r--r--LibMatrix/Homeservers/Extensions/NamedCaches/NamedFilterCache.cs2
-rw-r--r--LibMatrix/LegacyMatrixEvent.cs4
-rw-r--r--LibMatrix/LibMatrix.csproj4
-rw-r--r--LibMatrix/RoomTypes/GenericRoom.cs8
-rw-r--r--LibMatrix/Utilities/CommonSyncFilters.cs68
-rw-r--r--Utilities/LibMatrix.DebugDataValidationApi/JsonElementExtensions.cs (renamed from LibMatrix/Extensions/JsonElementExtensions.cs)0
-rw-r--r--Utilities/LibMatrix.DebugDataValidationApi/LibMatrix.DebugDataValidationApi.csproj4
-rw-r--r--Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs16
-rw-r--r--Utilities/LibMatrix.Utilities.Bot/Services/InviteListenerHostedService.cs16
25 files changed, 264 insertions, 69 deletions
diff --git a/ConsoleApp1/ConsoleApp1.csproj b/ConsoleApp1/ConsoleApp1.csproj
new file mode 100644
index 0000000..f30d408
--- /dev/null
+++ b/ConsoleApp1/ConsoleApp1.csproj
@@ -0,0 +1,14 @@
+<Project Sdk="Microsoft.NET.Sdk">

+

+  <PropertyGroup>

+    <OutputType>Exe</OutputType>

+    <TargetFramework>net8.0</TargetFramework>

+    <ImplicitUsings>enable</ImplicitUsings>

+    <Nullable>enable</Nullable>

+  </PropertyGroup>

+

+  <ItemGroup>

+    <ProjectReference Include="..\LibMatrix.EventTypes\LibMatrix.EventTypes.csproj" />

+  </ItemGroup>

+

+</Project>

diff --git a/ConsoleApp1/Program.cs b/ConsoleApp1/Program.cs
new file mode 100644
index 0000000..7831ce8
--- /dev/null
+++ b/ConsoleApp1/Program.cs
@@ -0,0 +1,25 @@
+// See https://aka.ms/new-console-template for more information

+

+using LibMatrix.EventTypes;

+using LibMatrix.EventTypes.Events;

+

+Console.WriteLine("Hello, World!");

+

+MatrixEventCollection collection = new();

+collection.Add(new MatrixEvent<RoomMembershipEventContent>() {

+    Content = new RoomMembershipEventContent() {

+        Membership = "yes"

+    }

+});

+

+List<MatrixEvent<MatrixEventContent>> collection2 = new();

+collection2.Add(new MatrixEvent<RoomMembershipEventContent>() {

+    Content = new RoomMembershipEventContent() {

+        Membership = "yes"

+    }

+});

+

+List<MatrixEventContent> collection3 = new();

+collection3.Add(new RoomMembershipEventContent() {

+    Membership = "yes"

+});
\ No newline at end of file
diff --git a/ExampleBots/ModerationBot b/ExampleBots/ModerationBot
-Subproject c137f94aeb122c636629fb9361dd73626594f69
+Subproject b5db50961eeedf24f0c969799e6f24830c973b0
diff --git a/LibMatrix.EventTypes/Events/RoomMembershipEventContent.cs b/LibMatrix.EventTypes/Events/RoomMembershipEventContent.cs
new file mode 100644
index 0000000..dac7094
--- /dev/null
+++ b/LibMatrix.EventTypes/Events/RoomMembershipEventContent.cs
@@ -0,0 +1,10 @@
+using System.Text.Json.Serialization;
+
+namespace LibMatrix.EventTypes.Events;
+
+public class RoomMembershipEventContent : MatrixEventContent {
+    public string Membership {
+        get => _json["membership"]!.GetValue<string>();
+        set => Console.WriteLine(value);
+    }
+}
\ No newline at end of file
diff --git a/LibMatrix.EventTypes/MatrixEvent.cs b/LibMatrix.EventTypes/MatrixEvent.cs
new file mode 100644
index 0000000..63f1e75
--- /dev/null
+++ b/LibMatrix.EventTypes/MatrixEvent.cs
@@ -0,0 +1,9 @@
+using System.Text.Json.Serialization;
+
+namespace LibMatrix.EventTypes;
+
+public interface IMatrixEvent<out T> where T : MatrixEventContent;
+public class MatrixEvent<T> : IMatrixEvent<T> where T : MatrixEventContent {
+    [JsonPropertyName("content")]
+    public T? Content { get; set; }
+}
\ No newline at end of file
diff --git a/LibMatrix.EventTypes/MatrixEventCollection.cs b/LibMatrix.EventTypes/MatrixEventCollection.cs
new file mode 100644
index 0000000..35afd2b
--- /dev/null
+++ b/LibMatrix.EventTypes/MatrixEventCollection.cs
@@ -0,0 +1,71 @@
+using System.Collections;
+
+namespace LibMatrix.EventTypes;
+
+public interface IMatrixEventCollection<out T> : IEnumerable<IMatrixEvent<T>> where T : MatrixEventContent {
+    
+}
+public class MatrixEventCollection : IMatrixEventCollection<MatrixEventContent>, IList<MatrixEvent<MatrixEventContent> {
+    private IList<MatrixEvent<MatrixEventContent>> _listImplementation;
+    public IEnumerator<MatrixEvent<MatrixEventContent>> GetEnumerator() => _listImplementation.GetEnumerator();
+
+    IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)_listImplementation).GetEnumerator();
+
+    public void Add(MatrixEvent<MatrixEventContent> item) => _listImplementation.Add(item);
+
+    public void Clear() => _listImplementation.Clear();
+
+    public bool Contains(MatrixEvent<MatrixEventContent> item) => _listImplementation.Contains(item);
+
+    public void CopyTo(MatrixEvent<MatrixEventContent>[] array, int arrayIndex) => _listImplementation.CopyTo(array, arrayIndex);
+
+    public bool Remove(MatrixEvent<MatrixEventContent> item) => _listImplementation.Remove(item);
+
+    public int Count => _listImplementation.Count;
+
+    public bool IsReadOnly => _listImplementation.IsReadOnly;
+
+    public int IndexOf(MatrixEvent<MatrixEventContent> item) => _listImplementation.IndexOf(item);
+
+    public void Insert(int index, MatrixEvent<MatrixEventContent> item) => _listImplementation.Insert(index, item);
+
+    public void RemoveAt(int index) => _listImplementation.RemoveAt(index);
+
+    public MatrixEvent<MatrixEventContent> this[int index] {
+        get => _listImplementation[index];
+        set => _listImplementation[index] = value;
+    }
+}
+public class MatrixEventCollection<T> : IMatrixEventCollection<T>, IList<MatrixEvent<T>> where T : MatrixEventContent {
+    //TODO: implement
+    
+    private IList<MatrixEvent<T>> _listImplementation = new List<MatrixEvent<T>>();
+    public IEnumerator<MatrixEvent<T>> GetEnumerator() => _listImplementation.GetEnumerator();
+
+    IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)_listImplementation).GetEnumerator();
+
+    public void Add(MatrixEvent<T> item) => _listImplementation.Add(item);
+
+    public void Clear() => _listImplementation.Clear();
+
+    public bool Contains(MatrixEvent<T> item) => _listImplementation.Contains(item);
+
+    public void CopyTo(MatrixEvent<T>[] array, int arrayIndex) => _listImplementation.CopyTo(array, arrayIndex);
+
+    public bool Remove(MatrixEvent<T> item) => _listImplementation.Remove(item);
+
+    public int Count => _listImplementation.Count;
+
+    public bool IsReadOnly => _listImplementation.IsReadOnly;
+
+    public int IndexOf(MatrixEvent<T> item) => _listImplementation.IndexOf(item);
+
+    public void Insert(int index, MatrixEvent<T> item) => _listImplementation.Insert(index, item);
+
+    public void RemoveAt(int index) => _listImplementation.RemoveAt(index);
+
+    public MatrixEvent<T> this[int index] {
+        get => _listImplementation[index];
+        set => _listImplementation[index] = value;
+    }
+}
\ No newline at end of file
diff --git a/LibMatrix.EventTypes/MatrixEventContent.cs b/LibMatrix.EventTypes/MatrixEventContent.cs
new file mode 100644
index 0000000..c30ebb0
--- /dev/null
+++ b/LibMatrix.EventTypes/MatrixEventContent.cs
@@ -0,0 +1,26 @@
+using System.Text.Json;
+using System.Text.Json.Nodes;
+using System.Text.Json.Serialization;
+
+namespace LibMatrix.EventTypes;
+
+/// <summary>
+///     Extensible Event Content, aims to provide an API similar to JsonNode/JsonObject
+///     <seealso cref="System.Text.Json.Nodes.JsonNode"/>
+///     <seealso cref="System.Text.Json.Nodes.JsonObject"/>
+/// </summary>
+public class MatrixEventContent {
+    // <T> : MatrixEventContent where T : MatrixEventContent<T>, new() {
+    internal JsonNode _json = new JsonObject();
+
+    public static implicit operator MatrixEventContent(JsonNode json) => new(json);
+
+    [JsonConstructor]
+    public MatrixEventContent(JsonNode json) {
+        _json = json;
+    }
+
+    public MatrixEventContent() { }
+
+    public JsonNode? this[string key] => _json[key];
+}
\ No newline at end of file
diff --git a/LibMatrix.EventTypes/temp/Temp.cs b/LibMatrix.EventTypes/temp/Temp.cs
new file mode 100644
index 0000000..3fbb401
--- /dev/null
+++ b/LibMatrix.EventTypes/temp/Temp.cs
@@ -0,0 +1,17 @@
+using LibMatrix.EventTypes.Events;
+
+namespace LibMatrix.EventTypes.temp;
+
+// public class Temp {
+//     public MatrixEventCollection<MatrixEventContent> Members = [
+//         new MatrixEvent<RoomMembershipEventContent>() {
+//             Content = new() {
+//                 Membership = "join"
+//             }
+//         }
+//     ];
+//
+//     public void a() {
+//         
+//     }
+// }
\ No newline at end of file
diff --git a/LibMatrix.sln b/LibMatrix.sln
index 257a8f2..df24832 100644
--- a/LibMatrix.sln
+++ b/LibMatrix.sln
@@ -39,6 +39,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibMatrix.HomeserverEmulato
 EndProject

 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibMatrix.EventTypes", "LibMatrix.EventTypes\LibMatrix.EventTypes.csproj", "{E9E9567D-58F4-4E17-BBC1-D4746C2526DB}"

 EndProject

+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{6254A2BA-279F-49F7-B3F3-675397F0F644}"

+EndProject

 Global

 	GlobalSection(SolutionConfigurationPlatforms) = preSolution

 		Debug|Any CPU = Debug|Any CPU

@@ -104,6 +106,10 @@ Global
 		{E9E9567D-58F4-4E17-BBC1-D4746C2526DB}.Debug|Any CPU.Build.0 = Debug|Any CPU

 		{E9E9567D-58F4-4E17-BBC1-D4746C2526DB}.Release|Any CPU.ActiveCfg = Release|Any CPU

 		{E9E9567D-58F4-4E17-BBC1-D4746C2526DB}.Release|Any CPU.Build.0 = Release|Any CPU

+		{6254A2BA-279F-49F7-B3F3-675397F0F644}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

+		{6254A2BA-279F-49F7-B3F3-675397F0F644}.Debug|Any CPU.Build.0 = Debug|Any CPU

+		{6254A2BA-279F-49F7-B3F3-675397F0F644}.Release|Any CPU.ActiveCfg = Release|Any CPU

+		{6254A2BA-279F-49F7-B3F3-675397F0F644}.Release|Any CPU.Build.0 = Release|Any CPU

 	EndGlobalSection

 	GlobalSection(NestedProjects) = preSolution

 		{1B1B2197-61FB-416F-B6C8-845F2E5A0442} = {840309F0-435B-43A7-8471-8C2BE643889D}

diff --git a/LibMatrix.sln.DotSettings.user b/LibMatrix.sln.DotSettings.user
index ec6bdc7..c5570e2 100644
--- a/LibMatrix.sln.DotSettings.user
+++ b/LibMatrix.sln.DotSettings.user
@@ -4,5 +4,9 @@
 	<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;
   &lt;Assembly Path="/home/root@Rory/.cache/NuGetPackages/microsoft.extensions.hosting.abstractions/7.0.0/lib/net7.0/Microsoft.Extensions.Hosting.Abstractions.dll" /&gt;
 &lt;/AssemblyExplorer&gt;</s:String>
+	<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=1b1b2197_002D61fb_002D416f_002Db6c8_002D845f2e5a0442_0023LibMatrix_002EExampleBot/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=345934ff_002Dca81_002D4a4b_002Db137_002D9f198102c65f_0023LibMatrix_002ETests/@EntryIndexedValue">True</s:Boolean>
-	<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=d44db78d_002D9bad_002D4ab6_002Da054_002D839eca9d68d2_0023LibMatrix_002EHomeserverEmulator/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
\ No newline at end of file
+	<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=35df9a1a_002Dd988_002D4225_002Dafa3_002D06bb8edeb559_0023LibMatrix_002EDebugDataValidationApi/@EntryIndexedValue">True</s:Boolean>
+	<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=8f0a820e_002Df6ae_002D45a2_002D970e_002D7a3759693919_0023ModerationBot/@EntryIndexedValue">True</s:Boolean>
+	<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=d44db78d_002D9bad_002D4ab6_002Da054_002D839eca9d68d2_0023LibMatrix_002EHomeserverEmulator/@EntryIndexedValue">True</s:Boolean>
+	<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=fb8fe4eb_002Db53b_002D464b_002Da5fd_002D9bf9d0f3ef9b_0023PluralContactBotPoC/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
\ No newline at end of file
diff --git a/LibMatrix/Extensions/EnumerableExtensions.cs b/LibMatrix/Extensions/EnumerableExtensions.cs
index b5193ab..7a810ac 100644
--- a/LibMatrix/Extensions/EnumerableExtensions.cs
+++ b/LibMatrix/Extensions/EnumerableExtensions.cs
@@ -1,6 +1,7 @@
 namespace LibMatrix.Extensions;
 
 public static class EnumerableExtensions {
+#if !DISABLE_LEGACY_EVENTS
     public static void MergeStateEventLists(this IList<LegacyMatrixEvent> oldState, IList<LegacyMatrixEvent> newState) {
         foreach (var stateEvent in newState) {
             var old = oldState.FirstOrDefault(x => x.Type == stateEvent.Type && x.StateKey == stateEvent.StateKey);
@@ -26,4 +27,5 @@ public static class EnumerableExtensions {
             oldState.Add(stateEvent);
         }
     }
+#endif
 }
\ No newline at end of file
diff --git a/LibMatrix/Filters/SyncFilter.cs b/LibMatrix/Filters/MatrixFilter.cs
index 787ffa7..08dc2fc 100644
--- a/LibMatrix/Filters/SyncFilter.cs
+++ b/LibMatrix/Filters/MatrixFilter.cs
@@ -2,7 +2,7 @@ using System.Text.Json.Serialization;
 
 namespace LibMatrix.Filters;
 
-public class SyncFilter {
+public class MatrixFilter {
     [JsonPropertyName("account_data")]
     public EventFilter? AccountData { get; set; }
 
diff --git a/LibMatrix/Helpers/MessageBuilder.cs b/LibMatrix/Helpers/MessageBuilder.cs
index 0ed0339..43999b3 100644
--- a/LibMatrix/Helpers/MessageBuilder.cs
+++ b/LibMatrix/Helpers/MessageBuilder.cs
@@ -1,3 +1,4 @@
+#if !DISABLE_LEGACY_EVENTS
 using LibMatrix.LegacyEvents.EventTypes.Spec;
 
 namespace LibMatrix.Helpers;
@@ -118,4 +119,6 @@ public class MessageBuilder(string msgType = "m.text", string format = "org.matr
             }
         }
     }
-}
\ No newline at end of file
+}
+
+#endif
\ No newline at end of file
diff --git a/LibMatrix/Helpers/SyncHelper.cs b/LibMatrix/Helpers/SyncHelper.cs
index 5635955..09bcf8e 100644
--- a/LibMatrix/Helpers/SyncHelper.cs
+++ b/LibMatrix/Helpers/SyncHelper.cs
@@ -9,7 +9,7 @@ using Microsoft.Extensions.Logging;
 namespace LibMatrix.Helpers;
 
 public class SyncHelper(AuthenticatedHomeserverGeneric homeserver, ILogger? logger = null) {
-    private SyncFilter? _filter;
+    private MatrixFilter? _filter;
     private string? _namedFilterName;
     private bool _filterIsDirty = false;
     private string? _filterId = null;
@@ -36,7 +36,7 @@ public class SyncHelper(AuthenticatedHomeserverGeneric homeserver, ILogger? logg
         }
     }
 
-    public SyncFilter? Filter {
+    public MatrixFilter? Filter {
         get => _filter;
         set {
             _filter = value;
diff --git a/LibMatrix/Helpers/SyncStateResolver.cs b/LibMatrix/Helpers/SyncStateResolver.cs
index b1f83ff..511819a 100644
--- a/LibMatrix/Helpers/SyncStateResolver.cs
+++ b/LibMatrix/Helpers/SyncStateResolver.cs
@@ -10,7 +10,7 @@ public class SyncStateResolver(AuthenticatedHomeserverGeneric homeserver, ILogge
     public string? Since { get; set; }
     public int Timeout { get; set; } = 30000;
     public string? SetPresence { get; set; } = "online";
-    public SyncFilter? Filter { get; set; }
+    public MatrixFilter? Filter { get; set; }
     public bool FullState { get; set; } = false;
 
     public SyncResponse? MergedState { get; set; }
diff --git a/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs b/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs
index db76985..96e20e0 100644
--- a/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs
+++ b/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs
@@ -192,8 +192,8 @@ public class AuthenticatedHomeserverGeneric : RemoteHomeserver {
         var oldProfile = await GetProfileAsync(WhoAmI.UserId!);
         Dictionary<string, RoomMemberLegacyEventContent> expectedRoomProfiles = new();
         var syncHelper = new SyncHelper(this) {
-            Filter = new SyncFilter {
-                AccountData = new SyncFilter.EventFilter() {
+            Filter = new MatrixFilter {
+                AccountData = new MatrixFilter.EventFilter() {
                     Types = new List<string> {
                         "m.room.member"
                     }
@@ -312,7 +312,7 @@ public class AuthenticatedHomeserverGeneric : RemoteHomeserver {
     /// <param name="filter"></param>
     /// <returns></returns>
     /// <exception cref="Exception"></exception>
-    public async Task<FilterIdResponse> UploadFilterAsync(SyncFilter filter) {
+    public async Task<FilterIdResponse> UploadFilterAsync(MatrixFilter filter) {
         List<List<string>?> senderLists = [
             filter.AccountData?.Senders,
             filter.AccountData?.NotSenders,
@@ -338,10 +338,10 @@ public class AuthenticatedHomeserverGeneric : RemoteHomeserver {
         return await resp.Content.ReadFromJsonAsync<FilterIdResponse>() ?? throw new Exception("Failed to upload filter?");
     }
 
-    public async Task<SyncFilter> GetFilterAsync(string filterId) {
+    public async Task<MatrixFilter> GetFilterAsync(string filterId) {
         if (_filterCache.TryGetValue(filterId, out var filter)) return filter;
         var resp = await ClientHttpClient.GetAsync("/_matrix/client/v3/user/" + UserId + "/filter/" + filterId);
-        return _filterCache[filterId] = await resp.Content.ReadFromJsonAsync<SyncFilter>() ?? throw new Exception("Failed to get filter?");
+        return _filterCache[filterId] = await resp.Content.ReadFromJsonAsync<MatrixFilter>() ?? throw new Exception("Failed to get filter?");
     }
 
     public class FilterIdResponse {
@@ -385,7 +385,7 @@ public class AuthenticatedHomeserverGeneric : RemoteHomeserver {
     }
 
     private Dictionary<string, string>? _namedFilterCache;
-    private Dictionary<string, SyncFilter> _filterCache = new();
+    private Dictionary<string, MatrixFilter> _filterCache = new();
 
     public async Task<JsonObject?> GetCapabilitiesAsync() {
         var res = await ClientHttpClient.GetAsync("/_matrix/client/v3/capabilities");
diff --git a/LibMatrix/Homeservers/Extensions/NamedCaches/NamedFilterCache.cs b/LibMatrix/Homeservers/Extensions/NamedCaches/NamedFilterCache.cs
index 76533a4..551ac39 100644
--- a/LibMatrix/Homeservers/Extensions/NamedCaches/NamedFilterCache.cs
+++ b/LibMatrix/Homeservers/Extensions/NamedCaches/NamedFilterCache.cs
@@ -13,7 +13,7 @@ public class NamedFilterCache(AuthenticatedHomeserverGeneric hs) : NamedCache<st
     /// <param name="filter">Filter to upload if not cached, otherwise defaults to common filters if that exists.</param>
     /// <returns></returns>
     /// <exception cref="ArgumentNullException"></exception>
-    public async Task<string> GetOrSetValueAsync(string key, SyncFilter? filter = null) {
+    public async Task<string> GetOrSetValueAsync(string key, MatrixFilter? filter = null) {
         var existingValue = await GetValueAsync(key);
         if (existingValue != null) {
             return existingValue;
diff --git a/LibMatrix/LegacyMatrixEvent.cs b/LibMatrix/LegacyMatrixEvent.cs
index 5433da3..a1ac5db 100644
--- a/LibMatrix/LegacyMatrixEvent.cs
+++ b/LibMatrix/LegacyMatrixEvent.cs
@@ -1,3 +1,4 @@
+#if !DISABLE_LEGACY_EVENTS
 using System.Collections.Frozen;
 using System.Diagnostics.CodeAnalysis;
 using System.Reflection;
@@ -222,4 +223,5 @@ public class StateEventContentPolymorphicTypeInfoResolver : DefaultJsonTypeInfoR
 }
 */
 
-#endregion
\ No newline at end of file
+#endregion
+#endif
\ No newline at end of file
diff --git a/LibMatrix/LibMatrix.csproj b/LibMatrix/LibMatrix.csproj
index 42ef17d..69f2bf4 100644
--- a/LibMatrix/LibMatrix.csproj
+++ b/LibMatrix/LibMatrix.csproj
@@ -8,6 +8,10 @@
 
         <Optimize>true</Optimize>
         <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
+        
+        <!-- event rewrite dev... -->
+        <DefineConstants Condition="!$(ExtraDefineConstants.Contains('WITH_LEGACY_EVENTS'))">$(DefineConstants);DISABLE_LEGACY_EVENTS</DefineConstants>
+        <DefineConstants Condition=" '$(ExtraDefineConstants)' != '' ">$(DefineConstants);$(ExtraDefineConstants)</DefineConstants>
     </PropertyGroup>
 
     <ItemGroup>
diff --git a/LibMatrix/RoomTypes/GenericRoom.cs b/LibMatrix/RoomTypes/GenericRoom.cs
index 8fa46d3..aafe29f 100644
--- a/LibMatrix/RoomTypes/GenericRoom.cs
+++ b/LibMatrix/RoomTypes/GenericRoom.cs
@@ -105,16 +105,16 @@ public class GenericRoom {
                 if (!fallbackToSync) throw;
                 Console.WriteLine("WARNING: Homeserver does not support getting event ID from state events, falling back to sync");
                 var sh = new SyncHelper(Homeserver);
-                var emptyFilter = new SyncFilter.EventFilter(types: [], limit: 1, senders: [], notTypes: ["*"]);
-                var emptyStateFilter = new SyncFilter.RoomFilter.StateFilter(types: [], limit: 1, senders: [], notTypes: ["*"], rooms:[]);
+                var emptyFilter = new MatrixFilter.EventFilter(types: [], limit: 1, senders: [], notTypes: ["*"]);
+                var emptyStateFilter = new MatrixFilter.RoomFilter.StateFilter(types: [], limit: 1, senders: [], notTypes: ["*"], rooms:[]);
                 sh.Filter = new() {
                     Presence = emptyFilter,
                     AccountData = emptyFilter,
-                    Room = new SyncFilter.RoomFilter() {
+                    Room = new MatrixFilter.RoomFilter() {
                         AccountData = emptyStateFilter,
                         Timeline = emptyStateFilter,
                         Ephemeral = emptyStateFilter,
-                        State = new SyncFilter.RoomFilter.StateFilter(),
+                        State = new MatrixFilter.RoomFilter.StateFilter(),
                         Rooms = [RoomId]
                     }
                 };
diff --git a/LibMatrix/Utilities/CommonSyncFilters.cs b/LibMatrix/Utilities/CommonSyncFilters.cs
index d07c225..68836f5 100644
--- a/LibMatrix/Utilities/CommonSyncFilters.cs
+++ b/LibMatrix/Utilities/CommonSyncFilters.cs
@@ -13,29 +13,29 @@ public static class CommonSyncFilters {
     public const string GetSpaceRelations = "gay.rory.matrixutils.get_space_relations.v0";
     public const string GetOwnMemberEvents = "gay.rory.matrixutils.get_own_member_events.v0";
 
-    public static SyncFilter GetAccountDataFilter => new() {
-        Presence = new SyncFilter.EventFilter(notTypes: ["*"]),
-        Room = new SyncFilter.RoomFilter() {
+    public static MatrixFilter GetAccountDataFilter => new() {
+        Presence = new MatrixFilter.EventFilter(notTypes: ["*"]),
+        Room = new MatrixFilter.RoomFilter() {
             Rooms = []
         }
     };
 
-    public static SyncFilter GetAccountDataWithRoomsFilter => new() {
-        Presence = new SyncFilter.EventFilter(notTypes: ["*"]),
-        Room = new SyncFilter.RoomFilter() {
-            State = new SyncFilter.RoomFilter.StateFilter(notTypes: ["*"]),
-            Ephemeral = new SyncFilter.RoomFilter.StateFilter(notTypes: ["*"]),
-            Timeline = new SyncFilter.RoomFilter.StateFilter(notTypes: ["*"])
+    public static MatrixFilter GetAccountDataWithRoomsFilter => new() {
+        Presence = new MatrixFilter.EventFilter(notTypes: ["*"]),
+        Room = new MatrixFilter.RoomFilter() {
+            State = new MatrixFilter.RoomFilter.StateFilter(notTypes: ["*"]),
+            Ephemeral = new MatrixFilter.RoomFilter.StateFilter(notTypes: ["*"]),
+            Timeline = new MatrixFilter.RoomFilter.StateFilter(notTypes: ["*"])
         }
     };
 
-    public static SyncFilter GetBasicRoomDataFilter => new() {
-        AccountData = new SyncFilter.EventFilter(notTypes: ["*"], limit: 1),
-        Presence = new SyncFilter.EventFilter(notTypes: ["*"], limit: 1),
-        Room = new SyncFilter.RoomFilter {
-            AccountData = new SyncFilter.RoomFilter.StateFilter(rooms: []),
-            Ephemeral = new SyncFilter.RoomFilter.StateFilter(rooms: []),
-            State = new SyncFilter.RoomFilter.StateFilter {
+    public static MatrixFilter GetBasicRoomDataFilter => new() {
+        AccountData = new MatrixFilter.EventFilter(notTypes: ["*"], limit: 1),
+        Presence = new MatrixFilter.EventFilter(notTypes: ["*"], limit: 1),
+        Room = new MatrixFilter.RoomFilter {
+            AccountData = new MatrixFilter.RoomFilter.StateFilter(rooms: []),
+            Ephemeral = new MatrixFilter.RoomFilter.StateFilter(rooms: []),
+            State = new MatrixFilter.RoomFilter.StateFilter {
                 Types = new List<string> {
                     RoomCreateLegacyEventContent.EventId,
                     RoomNameLegacyEventContent.EventId,
@@ -45,46 +45,46 @@ public static class CommonSyncFilters {
                 },
                 LazyLoadMembers = true, IncludeRedundantMembers = false
             },
-            Timeline = new SyncFilter.RoomFilter.StateFilter(rooms: [])
+            Timeline = new MatrixFilter.RoomFilter.StateFilter(rooms: [])
         }
     };
 
-    public static SyncFilter GetSpaceRelationsFilter => new() {
-        AccountData = new SyncFilter.EventFilter(notTypes: ["*"], limit: 1),
-        Presence = new SyncFilter.EventFilter(notTypes: ["*"], limit: 1),
-        Room = new SyncFilter.RoomFilter {
-            AccountData = new SyncFilter.RoomFilter.StateFilter(rooms: []),
-            Ephemeral = new SyncFilter.RoomFilter.StateFilter(rooms: []),
-            State = new SyncFilter.RoomFilter.StateFilter {
+    public static MatrixFilter GetSpaceRelationsFilter => new() {
+        AccountData = new MatrixFilter.EventFilter(notTypes: ["*"], limit: 1),
+        Presence = new MatrixFilter.EventFilter(notTypes: ["*"], limit: 1),
+        Room = new MatrixFilter.RoomFilter {
+            AccountData = new MatrixFilter.RoomFilter.StateFilter(rooms: []),
+            Ephemeral = new MatrixFilter.RoomFilter.StateFilter(rooms: []),
+            State = new MatrixFilter.RoomFilter.StateFilter {
                 Types = new List<string> {
                     SpaceChildLegacyEventContent.EventId,
                     SpaceParentLegacyEventContent.EventId
                 },
                 LazyLoadMembers = true, IncludeRedundantMembers = false
             },
-            Timeline = new SyncFilter.RoomFilter.StateFilter(rooms: [])
+            Timeline = new MatrixFilter.RoomFilter.StateFilter(rooms: [])
         }
     };
 
-    public static SyncFilter GetOwnMemberEventsFilter => new() {
-        AccountData = new SyncFilter.EventFilter(types: ["m.room.member"], limit: 1),
-        Presence = new SyncFilter.EventFilter(notTypes: ["*"], limit: 1),
-        Room = new SyncFilter.RoomFilter {
-            AccountData = new SyncFilter.RoomFilter.StateFilter(rooms: []),
-            Ephemeral = new SyncFilter.RoomFilter.StateFilter(rooms: []),
-            State = new SyncFilter.RoomFilter.StateFilter {
+    public static MatrixFilter GetOwnMemberEventsFilter => new() {
+        AccountData = new MatrixFilter.EventFilter(types: ["m.room.member"], limit: 1),
+        Presence = new MatrixFilter.EventFilter(notTypes: ["*"], limit: 1),
+        Room = new MatrixFilter.RoomFilter {
+            AccountData = new MatrixFilter.RoomFilter.StateFilter(rooms: []),
+            Ephemeral = new MatrixFilter.RoomFilter.StateFilter(rooms: []),
+            State = new MatrixFilter.RoomFilter.StateFilter {
                 Types = new List<string> {
                     RoomMemberLegacyEventContent.EventId
                 },
                 LazyLoadMembers = true, IncludeRedundantMembers = false,
                 Senders = ["@me"]
             },
-            Timeline = new SyncFilter.RoomFilter.StateFilter(rooms: [])
+            Timeline = new MatrixFilter.RoomFilter.StateFilter(rooms: [])
         }
     };
 
     // This must be down here, due to statics load order
-    public static FrozenDictionary<string, SyncFilter> FilterMap => new Dictionary<string, SyncFilter>() {
+    public static FrozenDictionary<string, MatrixFilter> FilterMap => new Dictionary<string, MatrixFilter>() {
         [GetAccountData] = GetAccountDataFilter,
         [GetAccountDataWithRooms] = GetAccountDataWithRoomsFilter,
         [GetBasicRoomInfo] = GetBasicRoomDataFilter,
diff --git a/LibMatrix/Extensions/JsonElementExtensions.cs b/Utilities/LibMatrix.DebugDataValidationApi/JsonElementExtensions.cs
index a2faddc..a2faddc 100644
--- a/LibMatrix/Extensions/JsonElementExtensions.cs
+++ b/Utilities/LibMatrix.DebugDataValidationApi/JsonElementExtensions.cs
diff --git a/Utilities/LibMatrix.DebugDataValidationApi/LibMatrix.DebugDataValidationApi.csproj b/Utilities/LibMatrix.DebugDataValidationApi/LibMatrix.DebugDataValidationApi.csproj
index 24fd617..ef8f443 100644
--- a/Utilities/LibMatrix.DebugDataValidationApi/LibMatrix.DebugDataValidationApi.csproj
+++ b/Utilities/LibMatrix.DebugDataValidationApi/LibMatrix.DebugDataValidationApi.csproj
@@ -14,7 +14,9 @@
     </ItemGroup>
 
     <ItemGroup>
-        <ProjectReference Include="..\..\LibMatrix\LibMatrix.csproj"/>
+        <ProjectReference Include="..\..\LibMatrix\LibMatrix.csproj">
+            <Properties>ExtraDefineConstants=WITH_LEGACY_EVENTS</Properties>
+        </ProjectReference>
     </ItemGroup>
 
 </Project>
diff --git a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
index 46638e4..45118b3 100644
--- a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
@@ -41,14 +41,14 @@ public class CommandListenerHostedService : IHostedService {
 
     private async Task? Run(CancellationToken cancellationToken) {
         _logger.LogInformation("Starting command listener!");
-        var filter = await _hs.NamedCaches.FilterCache.GetOrSetValueAsync("gay.rory.libmatrix.utilities.bot.command_listener_syncfilter.dev2", new SyncFilter() {
-            AccountData = new SyncFilter.EventFilter(notTypes: ["*"], limit: 1),
-            Presence = new SyncFilter.EventFilter(notTypes: ["*"]),
-            Room = new SyncFilter.RoomFilter() {
-                AccountData = new SyncFilter.RoomFilter.StateFilter(notTypes: ["*"]),
-                Ephemeral = new SyncFilter.RoomFilter.StateFilter(notTypes: ["*"]),
-                State = new SyncFilter.RoomFilter.StateFilter(notTypes: ["*"]),
-                Timeline = new SyncFilter.RoomFilter.StateFilter(types: ["m.room.message"], notSenders: [_hs.WhoAmI.UserId]),
+        var filter = await _hs.NamedCaches.FilterCache.GetOrSetValueAsync("gay.rory.libmatrix.utilities.bot.command_listener_syncfilter.dev2", new MatrixFilter() {
+            AccountData = new MatrixFilter.EventFilter(notTypes: ["*"], limit: 1),
+            Presence = new MatrixFilter.EventFilter(notTypes: ["*"]),
+            Room = new MatrixFilter.RoomFilter() {
+                AccountData = new MatrixFilter.RoomFilter.StateFilter(notTypes: ["*"]),
+                Ephemeral = new MatrixFilter.RoomFilter.StateFilter(notTypes: ["*"]),
+                State = new MatrixFilter.RoomFilter.StateFilter(notTypes: ["*"]),
+                Timeline = new MatrixFilter.RoomFilter.StateFilter(types: ["m.room.message"], notSenders: [_hs.WhoAmI.UserId]),
             }
         });
 
diff --git a/Utilities/LibMatrix.Utilities.Bot/Services/InviteListenerHostedService.cs b/Utilities/LibMatrix.Utilities.Bot/Services/InviteListenerHostedService.cs
index c2aed04..b49a8e3 100644
--- a/Utilities/LibMatrix.Utilities.Bot/Services/InviteListenerHostedService.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/Services/InviteListenerHostedService.cs
@@ -31,14 +31,14 @@ public class InviteHandlerHostedService : IHostedService {
 
     private async Task? Run(CancellationToken cancellationToken) {
         _logger.LogInformation("Starting invite listener!");
-        var filter = await _hs.NamedCaches.FilterCache.GetOrSetValueAsync("gay.rory.libmatrix.utilities.bot.command_listener_syncfilter.dev2", new SyncFilter() {
-            AccountData = new SyncFilter.EventFilter(notTypes: ["*"], limit: 1),
-            Presence = new SyncFilter.EventFilter(notTypes: ["*"]),
-            Room = new SyncFilter.RoomFilter() {
-                AccountData = new SyncFilter.RoomFilter.StateFilter(notTypes: ["*"]),
-                Ephemeral = new SyncFilter.RoomFilter.StateFilter(notTypes: ["*"]),
-                State = new SyncFilter.RoomFilter.StateFilter(notTypes: ["*"]),
-                Timeline = new SyncFilter.RoomFilter.StateFilter(types: ["m.room.message"], notSenders: [_hs.WhoAmI.UserId]),
+        var filter = await _hs.NamedCaches.FilterCache.GetOrSetValueAsync("gay.rory.libmatrix.utilities.bot.command_listener_syncfilter.dev2", new MatrixFilter() {
+            AccountData = new MatrixFilter.EventFilter(notTypes: ["*"], limit: 1),
+            Presence = new MatrixFilter.EventFilter(notTypes: ["*"]),
+            Room = new MatrixFilter.RoomFilter() {
+                AccountData = new MatrixFilter.RoomFilter.StateFilter(notTypes: ["*"]),
+                Ephemeral = new MatrixFilter.RoomFilter.StateFilter(notTypes: ["*"]),
+                State = new MatrixFilter.RoomFilter.StateFilter(notTypes: ["*"]),
+                Timeline = new MatrixFilter.RoomFilter.StateFilter(types: ["m.room.message"], notSenders: [_hs.WhoAmI.UserId]),
             }
         });