summary refs log tree commit diff
path: root/ModAS.Server/Services/AuthenticatedHomeserverProviderService.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-12-27 19:45:51 +0100
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-12-27 19:45:51 +0100
commitc04719d87abbe9feb94d9b3e8cf1812d3f7356e0 (patch)
tree68454b2f82300c887ddef475fa99f2560e38b611 /ModAS.Server/Services/AuthenticatedHomeserverProviderService.cs
parentTransactions test (diff)
downloadModAS-c04719d87abbe9feb94d9b3e8cf1812d3f7356e0.tar.xz
Room query v0
Diffstat (limited to '')
-rw-r--r--ModAS.Server/Services/AuthenticatedHomeserverProviderService.cs51
1 files changed, 0 insertions, 51 deletions
diff --git a/ModAS.Server/Services/AuthenticatedHomeserverProviderService.cs b/ModAS.Server/Services/AuthenticatedHomeserverProviderService.cs
deleted file mode 100644

index 1ceb095..0000000 --- a/ModAS.Server/Services/AuthenticatedHomeserverProviderService.cs +++ /dev/null
@@ -1,51 +0,0 @@ -using System.Collections.Concurrent; -using ArcaneLibs.Extensions; -using LibMatrix; -using LibMatrix.Homeservers; -using LibMatrix.Services; -using MxApiExtensions.Services; - -namespace ModAS.Server.Services; - -public class AuthenticatedHomeserverProviderService( - AuthenticationService authenticationService, - HomeserverProviderService homeserverProviderService, - IHttpContextAccessor request, - ModASConfiguration config, - AppServiceRegistration asRegistration - ) { - public HttpContext? _context = request.HttpContext; - public ConcurrentDictionary<string, AuthenticatedHomeserverGeneric> KnownUsers { get; set; } = new(); - - public async Task<AuthenticatedHomeserverGeneric> GetImpersonatedHomeserver(string mxid) { - if (!KnownUsers.TryGetValue(mxid, out var homeserver)) { - homeserver = await homeserverProviderService.GetAuthenticatedWithToken(config.ServerName, asRegistration.AppServiceToken, config.HomeserverUrl); - KnownUsers.TryAdd(mxid, homeserver); - } - //var hs = await homeserverProviderService.GetAuthenticatedWithToken(config.ServerName, asRegistration.AsToken, config.HomeserverUrl); - await homeserver.SetImpersonate(mxid); - // KnownUsers.TryAdd(mxid, homeserver); - return homeserver; - } - - public async Task<AuthenticatedHomeserverGeneric> GetHomeserver() { - var token = authenticationService.GetToken(); - if (token == null) { - throw new MatrixException { - ErrorCode = "M_MISSING_TOKEN", - Error = "Missing access token" - }; - } - - var mxid = await authenticationService.GetMxidFromToken(token); - if (mxid == "@anonymous:*") { - throw new MatrixException { - ErrorCode = "M_MISSING_TOKEN", - Error = "Missing access token" - }; - } - - var hsCanonical = string.Join(":", mxid.Split(':').Skip(1)); - return await homeserverProviderService.GetAuthenticatedWithToken(hsCanonical, token); - } -} \ No newline at end of file