about summary refs log tree commit diff
path: root/LibMatrix/RoomTypes/GenericRoom.cs
diff options
context:
space:
mode:
Diffstat (limited to 'LibMatrix/RoomTypes/GenericRoom.cs')
-rw-r--r--LibMatrix/RoomTypes/GenericRoom.cs6
1 files changed, 4 insertions, 2 deletions
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<StateEventResponse> 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<RecursedBatchedChunkedStateEventResponse>(uri);
         while (result!.Chunk.Count > 0) {
             foreach (var resp in result.Chunk) {