about summary refs log tree commit diff
path: root/LibMatrix/Utilities
diff options
context:
space:
mode:
authorEmma [it/its]@Rory& <root@rory.gay>2024-02-23 12:33:45 +0100
committerEmma [it/its]@Rory& <root@rory.gay>2024-02-23 12:33:55 +0100
commitc7b7dbe3d929d787fe0c76015082a117c4222278 (patch)
treedb765a9655f875d751f061e1000e199dd209d841 /LibMatrix/Utilities
parentHS emulator (diff)
downloadLibMatrix-c7b7dbe3d929d787fe0c76015082a117c4222278.tar.xz
Unknown changes
Diffstat (limited to 'LibMatrix/Utilities')
-rw-r--r--LibMatrix/Utilities/CommonSyncFilters.cs47
1 files changed, 34 insertions, 13 deletions
diff --git a/LibMatrix/Utilities/CommonSyncFilters.cs b/LibMatrix/Utilities/CommonSyncFilters.cs
index 8e727be..bf8b987 100644
--- a/LibMatrix/Utilities/CommonSyncFilters.cs
+++ b/LibMatrix/Utilities/CommonSyncFilters.cs
@@ -1,5 +1,7 @@
 using System.Collections.Frozen;
+using LibMatrix.EventTypes.Common;
 using LibMatrix.EventTypes.Spec.State;
+using LibMatrix.EventTypes.Spec.State.RoomInfo;
 using LibMatrix.Filters;
 
 namespace LibMatrix.Utilities;
@@ -9,15 +11,16 @@ public static class CommonSyncFilters {
     public const string GetAccountDataWithRooms = "gay.rory.libmatrix.get_account_data_with_rooms.v0";
     public const string GetBasicRoomInfo = "gay.rory.matrixutils.get_basic_room_info.v0";
     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 readonly SyncFilter GetAccountDataFilter = new() {
+    public static SyncFilter GetAccountDataFilter => new() {
         Presence = new SyncFilter.EventFilter(notTypes: ["*"]),
         Room = new SyncFilter.RoomFilter() {
             Rooms = []
         }
     };
 
-    public static readonly SyncFilter GetAccountDataWithRoomsFilter = new() {
+    public static SyncFilter GetAccountDataWithRoomsFilter => new() {
         Presence = new SyncFilter.EventFilter(notTypes: ["*"]),
         Room = new SyncFilter.RoomFilter() {
             State = new SyncFilter.RoomFilter.StateFilter(notTypes: ["*"]),
@@ -26,7 +29,7 @@ public static class CommonSyncFilters {
         }
     };
 
-    public static readonly SyncFilter GetBasicRoomDataFilter = new() {
+    public static SyncFilter GetBasicRoomDataFilter => new() {
         AccountData = new SyncFilter.EventFilter(notTypes: ["*"], limit: 1),
         Presence = new SyncFilter.EventFilter(notTypes: ["*"], limit: 1),
         Room = new SyncFilter.RoomFilter {
@@ -34,11 +37,11 @@ public static class CommonSyncFilters {
             Ephemeral = new SyncFilter.RoomFilter.StateFilter(rooms: []),
             State = new SyncFilter.RoomFilter.StateFilter {
                 Types = new List<string> {
-                    "m.room.create",
-                    "m.room.name",
-                    "m.room.avatar",
-                    "org.matrix.mjolnir.shortcode",
-                    "m.room.power_levels"
+                    RoomCreateEventContent.EventId,
+                    RoomNameEventContent.EventId,
+                    RoomAvatarEventContent.EventId,
+                    MjolnirShortcodeEventContent.EventId,
+                    RoomPowerLevelEventContent.EventId
                 },
                 LazyLoadMembers = true, IncludeRedundantMembers = false
             },
@@ -46,7 +49,7 @@ public static class CommonSyncFilters {
         }
     };
 
-    public static readonly SyncFilter GetSpaceRelationsFilter = new() {
+    public static SyncFilter GetSpaceRelationsFilter => new() {
         AccountData = new SyncFilter.EventFilter(notTypes: ["*"], limit: 1),
         Presence = new SyncFilter.EventFilter(notTypes: ["*"], limit: 1),
         Room = new SyncFilter.RoomFilter {
@@ -54,8 +57,8 @@ public static class CommonSyncFilters {
             Ephemeral = new SyncFilter.RoomFilter.StateFilter(rooms: []),
             State = new SyncFilter.RoomFilter.StateFilter {
                 Types = new List<string> {
-                    "m.space.child",
-                    "m.space.parent"
+                    SpaceChildEventContent.EventId,
+                    SpaceParentEventContent.EventId
                 },
                 LazyLoadMembers = true, IncludeRedundantMembers = false
             },
@@ -63,11 +66,29 @@ public static class CommonSyncFilters {
         }
     };
 
+    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 {
+                Types = new List<string> {
+                    RoomMemberEventContent.EventId
+                },
+                LazyLoadMembers = true, IncludeRedundantMembers = false,
+                Senders = ["@me"]
+            },
+            Timeline = new SyncFilter.RoomFilter.StateFilter(rooms: [])
+        }
+    };
+
     // This must be down here, due to statics load order
-    public static readonly FrozenDictionary<string, SyncFilter> FilterMap = new Dictionary<string, SyncFilter>() {
+    public static FrozenDictionary<string, SyncFilter> FilterMap => new Dictionary<string, SyncFilter>() {
         [GetAccountData] = GetAccountDataFilter,
         [GetAccountDataWithRooms] = GetAccountDataWithRoomsFilter,
         [GetBasicRoomInfo] = GetBasicRoomDataFilter,
-        [GetSpaceRelations] = GetSpaceRelationsFilter
+        [GetSpaceRelations] = GetSpaceRelationsFilter,
+        [GetOwnMemberEvents] = GetOwnMemberEventsFilter
     }.ToFrozenDictionary();
 }
\ No newline at end of file