From 3ed00f732a284b5a3e96e52d4e3a71869135869b Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 26 Jun 2023 02:43:54 +0200 Subject: Dependency injection stuff --- MatrixRoomUtils.Core/AuthenticatedHomeServer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'MatrixRoomUtils.Core/AuthenticatedHomeServer.cs') diff --git a/MatrixRoomUtils.Core/AuthenticatedHomeServer.cs b/MatrixRoomUtils.Core/AuthenticatedHomeServer.cs index 23e98ae..b7e01dd 100644 --- a/MatrixRoomUtils.Core/AuthenticatedHomeServer.cs +++ b/MatrixRoomUtils.Core/AuthenticatedHomeServer.cs @@ -42,14 +42,14 @@ public class AuthenticatedHomeServer : IHomeServer { return this; } - public async Task GetRoom(string roomId) => new Room(_httpClient, roomId); + public async Task GetRoom(string roomId) => new(this, roomId); - public async Task> GetJoinedRooms() { - var rooms = new List(); + public async Task> GetJoinedRooms() { + var rooms = new List(); var roomQuery = await _httpClient.GetAsync("/_matrix/client/v3/joined_rooms"); var roomsJson = await roomQuery.Content.ReadFromJsonAsync(); - foreach (var room in roomsJson.GetProperty("joined_rooms").EnumerateArray()) rooms.Add(new Room(_httpClient, room.GetString())); + foreach (var room in roomsJson.GetProperty("joined_rooms").EnumerateArray()) rooms.Add(new GenericRoom(this, room.GetString())); Console.WriteLine($"Fetched {rooms.Count} rooms"); @@ -67,7 +67,7 @@ public class AuthenticatedHomeServer : IHomeServer { return resJson.GetProperty("content_uri").GetString()!; } - public async Task CreateRoom(CreateRoomRequest creationEvent) { + public async Task CreateRoom(CreateRoomRequest creationEvent) { var res = await _httpClient.PostAsJsonAsync("/_matrix/client/v3/createRoom", creationEvent); if (!res.IsSuccessStatusCode) { Console.WriteLine($"Failed to create room: {await res.Content.ReadAsStringAsync()}"); -- cgit 1.5.1