about summary refs log tree commit diff
path: root/LibMatrix/RoomTypes/GenericRoom.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-02-08 21:03:41 +0100
committerRory& <root@rory.gay>2025-02-08 21:03:41 +0100
commitca3e6878422b7b55ae52b43f49f89a19546ea51c (patch)
treeae8b2724f9d43f88c1579cdade205876858a113c /LibMatrix/RoomTypes/GenericRoom.cs
parentUpdate ArcaneLibs (diff)
downloadLibMatrix-ca3e6878422b7b55ae52b43f49f89a19546ea51c.tar.xz
Temporary work
Diffstat (limited to 'LibMatrix/RoomTypes/GenericRoom.cs')
-rw-r--r--LibMatrix/RoomTypes/GenericRoom.cs12
1 files changed, 7 insertions, 5 deletions
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<MessagesResponse> GetMessagesAsync(string from = "", int? limit = null, string dir = "b", string filter = "") { + public async Task<MessagesResponse> 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<MessagesResponse>(url); return res; } @@ -151,12 +153,12 @@ public class GenericRoom { /// <summary> /// Same as <see cref="GetMessagesAsync"/>, except keeps fetching more responses until the beginning of the room is found, or the target message limit is reached /// </summary> - public async IAsyncEnumerable<MessagesResponse> GetManyMessagesAsync(string from = "", int limit = 100, string dir = "b", string filter = "", bool includeState = true, - bool fixForward = false, int chunkSize = 100) { + public async IAsyncEnumerable<MessagesResponse> 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<MessagesResponse>(); 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();