From 508c694c3d551cddb3b15c1b0d4787dae3c00530 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 2 May 2024 07:20:13 +0200 Subject: HomeserverEmulator work --- LibMatrix/RoomTypes/GenericRoom.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'LibMatrix/RoomTypes') diff --git a/LibMatrix/RoomTypes/GenericRoom.cs b/LibMatrix/RoomTypes/GenericRoom.cs index 43f3acc..742f5d9 100644 --- a/LibMatrix/RoomTypes/GenericRoom.cs +++ b/LibMatrix/RoomTypes/GenericRoom.cs @@ -517,18 +517,20 @@ public class GenericRoom { #endregion public async IAsyncEnumerable GetRelatedEventsAsync(string eventId, string? relationType = null, string? eventType = null, string? dir = "f", - string? from = null, int? chunkLimit = 100, bool? recurse = false, string? to = null) { - var path = $"/_matrix/client/v3/rooms/{RoomId}/relations/{eventId}"; + string? from = null, int? chunkLimit = 100, bool? recurse = null, string? to = null) { + var path = $"/_matrix/client/v1/rooms/{RoomId}/relations/{HttpUtility.UrlEncode(eventId)}"; if (!string.IsNullOrEmpty(relationType)) path += $"/{relationType}"; if (!string.IsNullOrEmpty(eventType)) path += $"/{eventType}"; var uri = new Uri(path, UriKind.Relative); if (dir == "b" || dir == "f") uri = uri.AddQuery("dir", dir); + else if(!string.IsNullOrWhiteSpace(dir)) throw new ArgumentException("Invalid direction", nameof(dir)); if (!string.IsNullOrEmpty(from)) uri = uri.AddQuery("from", from); if (chunkLimit is not null) uri = uri.AddQuery("limit", chunkLimit.Value.ToString()); if (recurse is not null) uri = uri.AddQuery("recurse", recurse.Value.ToString()); if (!string.IsNullOrEmpty(to)) uri = uri.AddQuery("to", to); + // Console.WriteLine($"Getting related events from {uri}"); var result = await Homeserver.ClientHttpClient.GetFromJsonAsync(uri); while (result!.Chunk.Count > 0) { foreach (var resp in result.Chunk) { -- cgit 1.4.1