From ca3e6878422b7b55ae52b43f49f89a19546ea51c Mon Sep 17 00:00:00 2001 From: Rory& Date: Sat, 8 Feb 2025 21:03:41 +0100 Subject: Temporary work --- LibMatrix/RoomTypes/GenericRoom.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'LibMatrix/RoomTypes') diff --git a/LibMatrix/RoomTypes/GenericRoom.cs b/LibMatrix/RoomTypes/GenericRoom.cs index b68a891..0863284 100644 --- a/LibMatrix/RoomTypes/GenericRoom.cs +++ b/LibMatrix/RoomTypes/GenericRoom.cs @@ -139,11 +139,13 @@ public class GenericRoom { } } - public async Task GetMessagesAsync(string from = "", int? limit = null, string dir = "b", string filter = "") { + public async Task GetMessagesAsync(string from = "", int? limit = null, string dir = "b", string? filter = "", SyncFilter.EventFilter? filterObject = null) { var url = $"/_matrix/client/v3/rooms/{RoomId}/messages?dir={dir}"; if (!string.IsNullOrWhiteSpace(from)) url += $"&from={from}"; if (limit is not null) url += $"&limit={limit}"; - if (!string.IsNullOrWhiteSpace(filter)) url += $"&filter={filter}"; + if(filterObject is not null) url += $"&filter={filterObject.ToJson()}"; + else if (!string.IsNullOrWhiteSpace(filter)) url += $"&filter={filter}"; + var res = await Homeserver.ClientHttpClient.GetFromJsonAsync(url); return res; } @@ -151,12 +153,12 @@ public class GenericRoom { /// /// Same as , except keeps fetching more responses until the beginning of the room is found, or the target message limit is reached /// - public async IAsyncEnumerable GetManyMessagesAsync(string from = "", int limit = 100, string dir = "b", string filter = "", bool includeState = true, - bool fixForward = false, int chunkSize = 100) { + public async IAsyncEnumerable GetManyMessagesAsync(string from = "", int limit = int.MaxValue, string dir = "b", string? filter = "", + SyncFilter.EventFilter? filterObject = null, bool includeState = true, bool fixForward = false, int chunkSize = 100) { if (dir == "f" && fixForward) { var concat = new List(); while (true) { - var resp = await GetMessagesAsync(from, int.MaxValue, "b", filter); + var resp = await GetMessagesAsync(from, int.MaxValue, "b", filter, filterObject); concat.Add(resp); if (!includeState) resp.State.Clear(); -- cgit 1.5.1