From ff13e64dca922550eb6a955de0690d841590a9b0 Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 26 Mar 2025 11:13:59 +0100 Subject: Split out invite context, add empty filter constants --- LibMatrix/Filters/SyncFilter.cs | 15 ++++++++++++++- LibMatrix/RoomTypes/GenericRoom.cs | 1 - LibMatrix/RoomTypes/PolicyRoom.cs | 8 ++++---- 3 files changed, 18 insertions(+), 6 deletions(-) (limited to 'LibMatrix') diff --git a/LibMatrix/Filters/SyncFilter.cs b/LibMatrix/Filters/SyncFilter.cs index 787ffa7..8c66656 100644 --- a/LibMatrix/Filters/SyncFilter.cs +++ b/LibMatrix/Filters/SyncFilter.cs @@ -34,6 +34,15 @@ public class SyncFilter { [JsonPropertyName("include_leave")] public bool? IncludeLeave { get; set; } + private static readonly RoomFilter Empty = new() { + Rooms = [], + IncludeLeave = false, + AccountData = StateFilter.Empty, + Ephemeral = StateFilter.Empty, + State = StateFilter.Empty, + Timeline = StateFilter.Empty, + }; + public class StateFilter( bool? containsUrl = null, bool? includeRedundantMembers = null, @@ -65,6 +74,8 @@ public class SyncFilter { [JsonPropertyName("unread_thread_notifications")] public bool? UnreadThreadNotifications { get; set; } = unreadThreadNotifications; + + public static readonly StateFilter Empty = new(limit: 0, senders: [], types: [], rooms: []); } } @@ -83,5 +94,7 @@ public class SyncFilter { [JsonPropertyName("not_senders")] public List? NotSenders { get; set; } = notSenders; + + public static readonly EventFilter Empty = new(limit: 0, senders: [], types: []); } -} \ No newline at end of file +} diff --git a/LibMatrix/RoomTypes/GenericRoom.cs b/LibMatrix/RoomTypes/GenericRoom.cs index cc3c0a1..55fa42c 100644 --- a/LibMatrix/RoomTypes/GenericRoom.cs +++ b/LibMatrix/RoomTypes/GenericRoom.cs @@ -304,7 +304,6 @@ public class GenericRoom { public Task GetPowerLevelsAsync() => GetStateAsync("m.room.power_levels"); - [Obsolete("This method will be merged into GetNameAsync() in the future.")] public async Task GetNameOrFallbackAsync(int maxMemberNames = 2) { try { var name = await GetNameAsync(); diff --git a/LibMatrix/RoomTypes/PolicyRoom.cs b/LibMatrix/RoomTypes/PolicyRoom.cs index e0b6edb..c6eec63 100644 --- a/LibMatrix/RoomTypes/PolicyRoom.cs +++ b/LibMatrix/RoomTypes/PolicyRoom.cs @@ -8,10 +8,10 @@ namespace LibMatrix.RoomTypes; public class PolicyRoom(AuthenticatedHomeserverGeneric homeserver, string roomId) : GenericRoom(homeserver, roomId) { public const string TypeName = "support.feline.policy.lists.msc.v1"; - private static readonly FrozenSet UserPolicyEventTypes = EventContent.GetMatchingEventTypes().ToFrozenSet(); - private static readonly FrozenSet ServerPolicyEventTypes = EventContent.GetMatchingEventTypes().ToFrozenSet(); - private static readonly FrozenSet RoomPolicyEventTypes = EventContent.GetMatchingEventTypes().ToFrozenSet(); - private static readonly FrozenSet SpecPolicyEventTypes = [..UserPolicyEventTypes, ..ServerPolicyEventTypes, ..RoomPolicyEventTypes]; + public static readonly FrozenSet UserPolicyEventTypes = EventContent.GetMatchingEventTypes().ToFrozenSet(); + public static readonly FrozenSet ServerPolicyEventTypes = EventContent.GetMatchingEventTypes().ToFrozenSet(); + public static readonly FrozenSet RoomPolicyEventTypes = EventContent.GetMatchingEventTypes().ToFrozenSet(); + public static readonly FrozenSet SpecPolicyEventTypes = [..UserPolicyEventTypes, ..ServerPolicyEventTypes, ..RoomPolicyEventTypes]; public async IAsyncEnumerable GetPoliciesAsync() { var fullRoomState = GetFullStateAsync(); -- cgit 1.5.1