diff --git a/LibMatrix/LibMatrix.csproj b/LibMatrix/LibMatrix.csproj
index 1fdf560..c074e81 100644
--- a/LibMatrix/LibMatrix.csproj
+++ b/LibMatrix/LibMatrix.csproj
@@ -18,7 +18,7 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="ArcaneLibs" Version="1.0.0-preview.20241122-053825" Condition="'$(Configuration)' == 'Release'"/>
+ <PackageReference Include="ArcaneLibs" Version="1.0.0-preview.20250123-182609" Condition="'$(Configuration)' == 'Release'"/>
<ProjectReference Include="..\ArcaneLibs\ArcaneLibs\ArcaneLibs.csproj" Condition="'$(Configuration)' == 'Debug'"/>
</ItemGroup>
diff --git a/LibMatrix/Responses/CreateRoomRequest.cs b/LibMatrix/Responses/CreateRoomRequest.cs
index 741bea1..1da6ff3 100644
--- a/LibMatrix/Responses/CreateRoomRequest.cs
+++ b/LibMatrix/Responses/CreateRoomRequest.cs
@@ -3,7 +3,6 @@ using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using LibMatrix.EventTypes;
-using LibMatrix.EventTypes.Spec.State;
using LibMatrix.EventTypes.Spec.State.RoomInfo;
using LibMatrix.Homeservers;
diff --git a/LibMatrix/RoomTypes/GenericRoom.cs b/LibMatrix/RoomTypes/GenericRoom.cs
index 14276d7..b68a891 100644
--- a/LibMatrix/RoomTypes/GenericRoom.cs
+++ b/LibMatrix/RoomTypes/GenericRoom.cs
@@ -7,7 +7,6 @@ using System.Web;
using ArcaneLibs.Extensions;
using LibMatrix.EventTypes;
using LibMatrix.EventTypes.Spec;
-using LibMatrix.EventTypes.Spec.State;
using LibMatrix.EventTypes.Spec.State.RoomInfo;
using LibMatrix.Filters;
using LibMatrix.Helpers;
diff --git a/LibMatrix/Services/HomeserverProviderService.cs b/LibMatrix/Services/HomeserverProviderService.cs
index 104a244..0fa0e83 100644
--- a/LibMatrix/Services/HomeserverProviderService.cs
+++ b/LibMatrix/Services/HomeserverProviderService.cs
@@ -7,9 +7,9 @@ using Microsoft.Extensions.Logging;
namespace LibMatrix.Services;
public class HomeserverProviderService(ILogger<HomeserverProviderService> logger, HomeserverResolverService hsResolver) {
- private static SemaphoreCache<AuthenticatedHomeserverGeneric> AuthenticatedHomeserverCache = new();
- private static SemaphoreCache<RemoteHomeserver> RemoteHomeserverCache = new();
- private static SemaphoreCache<FederationClient> FederationClientCache = new();
+ private static readonly SemaphoreCache<AuthenticatedHomeserverGeneric> AuthenticatedHomeserverCache = new();
+ private static readonly SemaphoreCache<RemoteHomeserver> RemoteHomeserverCache = new();
+ private static readonly SemaphoreCache<FederationClient> FederationClientCache = new();
public async Task<AuthenticatedHomeserverGeneric> GetAuthenticatedWithToken(string homeserver, string accessToken, string? proxy = null, string? impersonatedMxid = null,
bool useGeneric = false, bool enableClient = true, bool enableServer = true) {
@@ -22,7 +22,7 @@ public class HomeserverProviderService(ILogger<HomeserverProviderService> logger
AuthenticatedHomeserverGeneric? hs = null;
if (!useGeneric) {
- ClientVersionsResponse? clientVersions = new();
+ ClientVersionsResponse clientVersions = new();
try {
clientVersions = await rhs.GetClientVersionsAsync();
}
@@ -64,7 +64,7 @@ public class HomeserverProviderService(ILogger<HomeserverProviderService> logger
});
}
- public async Task<RemoteHomeserver> GetRemoteHomeserver(string homeserver, string? proxy = null, bool useCache = true, bool enableServer = true) =>
+ public async Task<RemoteHomeserver> GetRemoteHomeserver(string homeserver, string? proxy = null, bool useCache = true, bool enableServer = false) =>
useCache
? await RemoteHomeserverCache.GetOrAdd($"{homeserver}{proxy}",
async () => { return new RemoteHomeserver(homeserver, await hsResolver.ResolveHomeserverFromWellKnown(homeserver, enableServer: enableServer), proxy); })
diff --git a/LibMatrix/Services/HomeserverResolverService.cs b/LibMatrix/Services/HomeserverResolverService.cs
index ddbc335..fa75f1e 100644
--- a/LibMatrix/Services/HomeserverResolverService.cs
+++ b/LibMatrix/Services/HomeserverResolverService.cs
@@ -9,9 +9,7 @@ using Microsoft.Extensions.Logging.Abstractions;
namespace LibMatrix.Services;
public class HomeserverResolverService {
- private readonly MatrixHttpClient _httpClient = new() {
- // Timeout = TimeSpan.FromSeconds(60) // TODO: Re-implement this
- };
+ private readonly MatrixHttpClient _httpClient = new();
private static readonly SemaphoreCache<WellKnownUris> WellKnownCache = new();
@@ -22,49 +20,31 @@ public class HomeserverResolverService {
if (logger is NullLogger<HomeserverResolverService>) {
var stackFrame = new StackTrace(true).GetFrame(1);
Console.WriteLine(
- $"WARN | Null logger provided to HomeserverResolverService!\n{stackFrame.GetMethod().DeclaringType} at {stackFrame.GetFileName()}:{stackFrame.GetFileLineNumber()}");
+ $"WARN | Null logger provided to HomeserverResolverService!\n{stackFrame?.GetMethod()?.DeclaringType?.ToString() ?? "null"} at {stackFrame?.GetFileName() ?? "null"}:{stackFrame?.GetFileLineNumber().ToString() ?? "null"}");
}
}
- // private static SemaphoreSlim _wellKnownSemaphore = new(1, 1);
-
public async Task<WellKnownUris> ResolveHomeserverFromWellKnown(string homeserver, bool enableClient = true, bool enableServer = true) {
ArgumentNullException.ThrowIfNull(homeserver);
return await WellKnownCache.GetOrAdd(homeserver, async () => {
- // await _wellKnownSemaphore.WaitAsync();
_logger.LogTrace($"Resolving homeserver well-knowns: {homeserver}");
var client = enableClient ? _tryResolveClientEndpoint(homeserver) : null;
var server = enableServer ? _tryResolveServerEndpoint(homeserver) : null;
var res = new WellKnownUris();
- // try {
if (client != null)
res.Client = (await client)?.TrimEnd('/') ?? throw new Exception($"Could not resolve client URL for {homeserver}.");
- // }
- // catch (Exception e) {
- // _logger.LogError(e, "Error resolving client well-known for {hs}", homeserver);
- // }
- // try {
if (server != null)
res.Server = (await server)?.TrimEnd('/') ?? throw new Exception($"Could not resolve server URL for {homeserver}.");
- // }
- // catch (Exception e) {
- // _logger.LogError(e, "Error resolving server well-known for {hs}", homeserver);
- // }
_logger.LogInformation("Resolved well-knowns for {hs}: {json}", homeserver, res.ToJson(indent: false));
- // _wellKnownSemaphore.Release();
return res;
});
}
- // private async Task<WellKnownUris> InternalResolveHomeserverFromWellKnown(string homeserver) {
-
- // }
-
private async Task<string?> _tryResolveClientEndpoint(string homeserver) {
ArgumentNullException.ThrowIfNull(homeserver);
_logger.LogTrace("Resolving client well-known: {homeserver}", homeserver);
@@ -133,7 +113,8 @@ public class HomeserverResolverService {
_logger.LogInformation("No server well-known for {server}...", homeserver);
return null;
}
-
+
+ [Obsolete("Use authenticated media, available on AuthenticatedHomeserverGeneric", true)]
public async Task<string?> ResolveMediaUri(string homeserver, string mxc) {
if (homeserver is null) throw new ArgumentNullException(nameof(homeserver));
if (mxc is null) throw new ArgumentNullException(nameof(mxc));
diff --git a/LibMatrix/Utilities/CommonSyncFilters.cs b/LibMatrix/Utilities/CommonSyncFilters.cs
index 65c9564..503cc1f 100644
--- a/LibMatrix/Utilities/CommonSyncFilters.cs
+++ b/LibMatrix/Utilities/CommonSyncFilters.cs
@@ -1,6 +1,5 @@
using System.Collections.Frozen;
using LibMatrix.EventTypes.Common;
-using LibMatrix.EventTypes.Spec.State;
using LibMatrix.EventTypes.Spec.State.RoomInfo;
using LibMatrix.EventTypes.Spec.State.Space;
using LibMatrix.Filters;
|