diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-12-23 12:07:34 +0100 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-12-23 12:07:34 +0100 |
commit | a847c172069c27fccd95fc593a1b0c630a620d4f (patch) | |
tree | 78fe3f1d20af02738421eb020cedd417b51b8305 /ModAS.Server/Services/AuthenticatedHomeserverProviderService.cs | |
parent | Basic test (diff) | |
download | ModAS-a847c172069c27fccd95fc593a1b0c630a620d4f.tar.xz |
Transactions test
Diffstat (limited to 'ModAS.Server/Services/AuthenticatedHomeserverProviderService.cs')
-rw-r--r-- | ModAS.Server/Services/AuthenticatedHomeserverProviderService.cs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ModAS.Server/Services/AuthenticatedHomeserverProviderService.cs b/ModAS.Server/Services/AuthenticatedHomeserverProviderService.cs index fa8e00a..1ceb095 100644 --- a/ModAS.Server/Services/AuthenticatedHomeserverProviderService.cs +++ b/ModAS.Server/Services/AuthenticatedHomeserverProviderService.cs @@ -1,3 +1,4 @@ +using System.Collections.Concurrent; using ArcaneLibs.Extensions; using LibMatrix; using LibMatrix.Homeservers; @@ -14,14 +15,17 @@ public class AuthenticatedHomeserverProviderService( AppServiceRegistration asRegistration ) { public HttpContext? _context = request.HttpContext; - public Dictionary<string, AuthenticatedHomeserverGeneric> KnownUsers { get; set; } = new(); + public ConcurrentDictionary<string, AuthenticatedHomeserverGeneric> KnownUsers { get; set; } = new(); public async Task<AuthenticatedHomeserverGeneric> GetImpersonatedHomeserver(string mxid) { - if (KnownUsers.TryGetValue(mxid, out var homeserver)) return homeserver; - var hs = await homeserverProviderService.GetAuthenticatedWithToken(config.ServerName, asRegistration.AsToken, config.HomeserverUrl); - await hs.SetImpersonate(mxid); - KnownUsers.TryAdd(mxid, hs); - return hs; + 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() { |