about summary refs log tree commit diff
path: root/LibMatrix/Services/HomeserverProviderService.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-06 18:29:15 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-06 18:29:15 +0200
commite5591eef3850a9796cc87386128651a828b70697 (patch)
tree7e501ec749229a3d96838265289266bb6f6ce208 /LibMatrix/Services/HomeserverProviderService.cs
parentUnit tests, small refactors (diff)
downloadLibMatrix-e5591eef3850a9796cc87386128651a828b70697.tar.xz
Small refactors
Diffstat (limited to 'LibMatrix/Services/HomeserverProviderService.cs')
-rw-r--r--LibMatrix/Services/HomeserverProviderService.cs11
1 files changed, 3 insertions, 8 deletions
diff --git a/LibMatrix/Services/HomeserverProviderService.cs b/LibMatrix/Services/HomeserverProviderService.cs
index 666d2a2..1f3bd37 100644
--- a/LibMatrix/Services/HomeserverProviderService.cs
+++ b/LibMatrix/Services/HomeserverProviderService.cs
@@ -35,20 +35,15 @@ public class HomeserverProviderService {
         }
 
         var domain = proxy ?? await _homeserverResolverService.ResolveHomeserverFromWellKnown(homeserver);
-        var hc = new MatrixHttpClient { BaseAddress = new Uri(domain) };
 
         AuthenticatedHomeserverGeneric hs;
         if (true) {
-            hs = new AuthenticatedHomeserverMxApiExtended(homeserver, accessToken);
+            hs = await AuthenticatedHomeserverGeneric.Create<AuthenticatedHomeserverMxApiExtended>(homeserver, accessToken);
         }
         else {
-            hs = new AuthenticatedHomeserverGeneric(homeserver, accessToken);
+            hs = await AuthenticatedHomeserverGeneric.Create<AuthenticatedHomeserverSynapse>(homeserver, accessToken);
         }
 
-        hs._httpClient = hc;
-        hs._httpClient.Timeout = TimeSpan.FromMinutes(15);
-        hs._httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
-
         // (() => hs.WhoAmI) = (await hs._httpClient.GetFromJsonAsync<WhoAmIResponse>("/_matrix/client/v3/account/whoami"))!;
 
         lock(_authenticatedHomeServerCache)
@@ -59,7 +54,7 @@ public class HomeserverProviderService {
     }
 
     public async Task<RemoteHomeServer> GetRemoteHomeserver(string homeserver, string? proxy = null) {
-        var hs = new RemoteHomeServer(proxy ?? await _homeserverResolverService.ResolveHomeserverFromWellKnown(homeserver));
+        var hs = await RemoteHomeServer.Create(proxy ?? await _homeserverResolverService.ResolveHomeserverFromWellKnown(homeserver));
         // hs._httpClient.Dispose();
         // hs._httpClient = new MatrixHttpClient { BaseAddress = new Uri(hs.FullHomeServerDomain) };
         // hs._httpClient.Timeout = TimeSpan.FromSeconds(120);