diff options
author | Emma [it/its]@Rory& <root@rory.gay> | 2023-12-14 07:20:46 +0100 |
---|---|---|
committer | Emma [it/its]@Rory& <root@rory.gay> | 2023-12-14 07:20:46 +0100 |
commit | 5affd9f061e75f6575a2fe6715f9e8757cfe87e8 (patch) | |
tree | 13ea35ce981094a960746777a16dff8815c45e55 /LibMatrix/Homeservers/RemoteHomeServer.cs | |
parent | Temp state (diff) | |
download | LibMatrix-5affd9f061e75f6575a2fe6715f9e8757cfe87e8.tar.xz |
Cleanup
Diffstat (limited to 'LibMatrix/Homeservers/RemoteHomeServer.cs')
-rw-r--r-- | LibMatrix/Homeservers/RemoteHomeServer.cs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/LibMatrix/Homeservers/RemoteHomeServer.cs b/LibMatrix/Homeservers/RemoteHomeServer.cs index f8d61fd..a47b731 100644 --- a/LibMatrix/Homeservers/RemoteHomeServer.cs +++ b/LibMatrix/Homeservers/RemoteHomeServer.cs @@ -2,7 +2,6 @@ using System.Net.Http.Json; using System.Text.Json; using System.Text.Json.Serialization; using ArcaneLibs.Extensions; -using LibMatrix.EventTypes.Spec.State; using LibMatrix.Extensions; using LibMatrix.Responses; using LibMatrix.Services; @@ -10,6 +9,7 @@ using LibMatrix.Services; namespace LibMatrix.Homeservers; public class RemoteHomeserver(string baseUrl) { + public static async Task<RemoteHomeserver> Create(string baseUrl, string? proxy = null) { var homeserver = new RemoteHomeserver(baseUrl); homeserver.WellKnownUris = await new HomeserverResolverService().ResolveHomeserverFromWellKnown(baseUrl); @@ -32,9 +32,10 @@ public class RemoteHomeserver(string baseUrl) { private Dictionary<string, object> _profileCache { get; set; } = new(); public string BaseUrl { get; } = baseUrl; - public MatrixHttpClient ClientHttpClient { get; set; } - public MatrixHttpClient ServerHttpClient { get; set; } - public HomeserverResolverService.WellKnownUris WellKnownUris { get; set; } + + public MatrixHttpClient ClientHttpClient { get; set; } = null!; + public MatrixHttpClient ServerHttpClient { get; set; } = null!; + public HomeserverResolverService.WellKnownUris WellKnownUris { get; set; } = null!; public async Task<UserProfileResponse> GetProfileAsync(string mxid) { if (mxid is null) throw new ArgumentNullException(nameof(mxid)); @@ -63,7 +64,7 @@ public class RemoteHomeserver(string baseUrl) { public async Task<AliasResult> ResolveRoomAliasAsync(string alias) { var resp = await ClientHttpClient.GetAsync($"/_matrix/client/v3/directory/room/{alias.Replace("#", "%23")}"); var data = await resp.Content.ReadFromJsonAsync<AliasResult>(); - var text = await resp.Content.ReadAsStringAsync(); + //var text = await resp.Content.ReadAsStringAsync(); if (!resp.IsSuccessStatusCode) Console.WriteLine("ResolveAlias: " + data.ToJson()); return data; } @@ -119,8 +120,9 @@ public class RemoteHomeserver(string baseUrl) { public class ServerVersionResponse { [JsonPropertyName("server")] - public ServerInfo Server { get; set; } + public required ServerInfo Server { get; set; } + // ReSharper disable once ClassNeverInstantiated.Global public class ServerInfo { [JsonPropertyName("name")] public string Name { get; set; } |