summary refs log tree commit diff
path: root/MxApiExtensions/Services
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-12-01 12:34:30 +0100
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-12-01 12:34:30 +0100
commit0b662d36de30c4bdd3d9be97d08ace8d4d7be588 (patch)
tree475e4ea94cb5179236614bf5052d3164d1f2ff3b /MxApiExtensions/Services
parentAdd more code (diff)
downloadMxApiExtensions-0b662d36de30c4bdd3d9be97d08ace8d4d7be588.tar.xz
Reformat
Diffstat (limited to 'MxApiExtensions/Services')
-rw-r--r--MxApiExtensions/Services/AuthenticatedHomeserverProviderService.cs4
-rw-r--r--MxApiExtensions/Services/AuthenticationService.cs10
-rw-r--r--MxApiExtensions/Services/UserContextService.cs2
3 files changed, 8 insertions, 8 deletions
diff --git a/MxApiExtensions/Services/AuthenticatedHomeserverProviderService.cs b/MxApiExtensions/Services/AuthenticatedHomeserverProviderService.cs
index 741beb3..296663d 100644
--- a/MxApiExtensions/Services/AuthenticatedHomeserverProviderService.cs
+++ b/MxApiExtensions/Services/AuthenticatedHomeserverProviderService.cs
@@ -15,7 +15,7 @@ public class AuthenticatedHomeserverProviderService(AuthenticationService authen
             return null;
         }
     }
-    
+
     public async Task<RemoteHomeserver> GetRemoteHomeserver() {
         try {
             return await GetHomeserver();
@@ -23,7 +23,7 @@ public class AuthenticatedHomeserverProviderService(AuthenticationService authen
         catch (MxApiMatrixException e) {
             if (e is not { ErrorCode: "M_MISSING_TOKEN" }) throw;
             if (request is null) throw new MxApiMatrixException() { ErrorCode = "M_UNKNOWN", Error = "[MxApiExtensions] Request was null for unauthenticated request!" };
-            if (!_context.Request.Headers.Keys.Any(x=>x.ToUpper() == "MXAE_UPSTREAM"))
+            if (!_context.Request.Headers.Keys.Any(x => x.ToUpper() == "MXAE_UPSTREAM"))
                 throw new MxApiMatrixException() {
                     ErrorCode = "MXAE_MISSING_UPSTREAM",
                     Error = "[MxApiExtensions] Missing MXAE_UPSTREAM header for unauthenticated request, this should be a server_name!"
diff --git a/MxApiExtensions/Services/AuthenticationService.cs b/MxApiExtensions/Services/AuthenticationService.cs
index 7430fcd..6a45214 100644
--- a/MxApiExtensions/Services/AuthenticationService.cs
+++ b/MxApiExtensions/Services/AuthenticationService.cs
@@ -42,11 +42,11 @@ public class AuthenticationService(ILogger<AuthenticationService> logger, MxApiE
             return "@anonymous:*";
         }
 
-        if(_tokenMap is not { Count: >0 } && File.Exists("token_map")) {
+        if (_tokenMap is not { Count: > 0 } && File.Exists("token_map")) {
             _tokenMap = (await File.ReadAllLinesAsync("token_map"))
                 .Select(l => l.Split('\t'))
                 .ToDictionary(l => l[0], l => l[1]);
-            
+
             //THIS IS BROKEN, DO NOT USE!
             // foreach (var (mapToken, mapUser) in _tokenMap) {
             //     try {
@@ -62,7 +62,7 @@ public class AuthenticationService(ILogger<AuthenticationService> logger, MxApiE
             // _tokenMap.RemoveAll((x, y) => string.IsNullOrWhiteSpace(y));
             // await File.WriteAllTextAsync("token_map", _tokenMap.Aggregate("", (x, y) => $"{y.Key}\t{y.Value}\n"));
         }
-        
+
 
         if (_tokenMap.TryGetValue(token, out var mxid)) return mxid;
 
@@ -73,12 +73,12 @@ public class AuthenticationService(ILogger<AuthenticationService> logger, MxApiE
                 await lookupTasks[homeserver].WaitAsync(TimeSpan.FromMilliseconds(500));
                 if (lookupTasks[homeserver].IsCompletedSuccessfully && !string.IsNullOrWhiteSpace(lookupTasks[homeserver].Result)) break;
             }
-            catch {}
+            catch { }
         }
         await Task.WhenAll(lookupTasks.Values);
 
         mxid = lookupTasks.Values.FirstOrDefault(x => x.Result != null)?.Result;
-        if(mxid is null) {
+        if (mxid is null) {
             throw new MxApiMatrixException {
                 ErrorCode = "M_UNKNOWN_TOKEN",
                 Error = "Token not found on any configured homeservers: " + string.Join(", ", config.AuthHomeservers)
diff --git a/MxApiExtensions/Services/UserContextService.cs b/MxApiExtensions/Services/UserContextService.cs
index d5ef282..7c96990 100644
--- a/MxApiExtensions/Services/UserContextService.cs
+++ b/MxApiExtensions/Services/UserContextService.cs
@@ -41,4 +41,4 @@ public class UserContextService(MxApiExtensionsConfiguration config, Authenticat
         // _getUserContextSemaphore.Release();
         return ucs;
     }
-}
\ No newline at end of file
+}