From 6bd02248ccfbcb46960a6f39eaad23888d190eb5 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Fri, 15 Sep 2023 09:50:45 +0200 Subject: Some refactoring --- LibMatrix/Filters/SyncFilter.cs | 45 ++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'LibMatrix/Filters/SyncFilter.cs') diff --git a/LibMatrix/Filters/SyncFilter.cs b/LibMatrix/Filters/SyncFilter.cs index c907f6b..e3e8164 100644 --- a/LibMatrix/Filters/SyncFilter.cs +++ b/LibMatrix/Filters/SyncFilter.cs @@ -1,3 +1,4 @@ +using System.Reflection.Metadata; using System.Text.Json.Serialization; namespace LibMatrix.Filters; @@ -25,42 +26,58 @@ public class SyncFilter { [JsonPropertyName("timeline")] public StateFilter? Timeline { get; set; } - - public class StateFilter : EventFilter { + public class StateFilter(bool? containsUrl = null, bool? includeRedundantMembers = null, bool? lazyLoadMembers = null, List? rooms = null, + List? notRooms = null, bool? unreadThreadNotifications = null, + //base ctor + int? limit = null, List? types = null, List? notTypes = null, List? senders = null, List? notSenders = null + ) : EventFilter(limit: limit, types: types, notTypes: notTypes, senders: senders, notSenders: notSenders) { [JsonPropertyName("contains_url")] - public bool? ContainsUrl { get; set; } + public bool? ContainsUrl { get; set; } = containsUrl; [JsonPropertyName("include_redundant_members")] - public bool? IncludeRedundantMembers { get; set; } + public bool? IncludeRedundantMembers { get; set; } = includeRedundantMembers; [JsonPropertyName("lazy_load_members")] - public bool? LazyLoadMembers { get; set; } + public bool? LazyLoadMembers { get; set; } = lazyLoadMembers; [JsonPropertyName("rooms")] - public List? Rooms { get; set; } + public List? Rooms { get; set; } = rooms; [JsonPropertyName("not_rooms")] - public List? NotRooms { get; set; } + public List? NotRooms { get; set; } = notRooms; [JsonPropertyName("unread_thread_notifications")] - public bool? UnreadThreadNotifications { get; set; } + public bool? UnreadThreadNotifications { get; set; } = unreadThreadNotifications; } } - public class EventFilter { + public class EventFilter(int? limit = null, List? types = null, List? notTypes = null, List? senders = null, List? notSenders = null) { [JsonPropertyName("limit")] - public int? Limit { get; set; } + public int? Limit { get; set; } = limit; [JsonPropertyName("types")] - public List? Types { get; set; } + public List? Types { get; set; } = types; [JsonPropertyName("not_types")] - public List? NotTypes { get; set; } + public List? NotTypes { get; set; } = notTypes; [JsonPropertyName("senders")] - public List? Senders { get; set; } + public List? Senders { get; set; } = senders; [JsonPropertyName("not_senders")] - public List? NotSenders { get; set; } + public List? NotSenders { get; set; } = notSenders; } } + +public static class ExampleFilters { + public static readonly SyncFilter Limit1Filter = new() { + Presence = new(limit: 1), + Room = new() { + AccountData = new(limit: 1), + Ephemeral = new(limit: 1), + State = new(limit: 1), + Timeline = new(limit: 1), + }, + AccountData = new(limit: 1) + }; +} -- cgit 1.4.1