summary refs log tree commit diff
path: root/MxApiExtensions/Controllers
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/Controllers
parentAdd more code (diff)
downloadMxApiExtensions-0b662d36de30c4bdd3d9be97d08ace8d4d7be588.tar.xz
Reformat
Diffstat (limited to '')
-rw-r--r--MxApiExtensions/Controllers/Client/LoginController.cs2
-rw-r--r--MxApiExtensions/Controllers/Client/Room/RoomController.cs2
-rw-r--r--MxApiExtensions/Controllers/Client/Room/RoomsSendMessageController.cs2
-rw-r--r--MxApiExtensions/Controllers/Client/SyncController.cs2
-rw-r--r--MxApiExtensions/Controllers/Extensions/DebugController.cs2
-rw-r--r--MxApiExtensions/Controllers/Extensions/JoinedRoomListController.cs16
-rw-r--r--MxApiExtensions/Controllers/Extensions/ProxyConfigurationController.cs2
-rw-r--r--MxApiExtensions/Controllers/Other/GenericProxyController.cs2
-rw-r--r--MxApiExtensions/Controllers/Other/MediaProxyController.cs20
9 files changed, 25 insertions, 25 deletions
diff --git a/MxApiExtensions/Controllers/Client/LoginController.cs b/MxApiExtensions/Controllers/Client/LoginController.cs
index 009aaef..bf44af1 100644
--- a/MxApiExtensions/Controllers/Client/LoginController.cs
+++ b/MxApiExtensions/Controllers/Client/LoginController.cs
@@ -70,4 +70,4 @@ public class LoginController(ILogger<LoginController> logger, HomeserverProvider
             }
         };
     }
-}
\ No newline at end of file
+}
diff --git a/MxApiExtensions/Controllers/Client/Room/RoomController.cs b/MxApiExtensions/Controllers/Client/Room/RoomController.cs
index a3e433d..7e7bfc1 100644
--- a/MxApiExtensions/Controllers/Client/Room/RoomController.cs
+++ b/MxApiExtensions/Controllers/Client/Room/RoomController.cs
@@ -48,4 +48,4 @@ public class RoomController(ILogger<LoginController> logger, HomeserverResolverS
                 }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/MxApiExtensions/Controllers/Client/Room/RoomsSendMessageController.cs b/MxApiExtensions/Controllers/Client/Room/RoomsSendMessageController.cs
index e882c8a..b800ec6 100644
--- a/MxApiExtensions/Controllers/Client/Room/RoomsSendMessageController.cs
+++ b/MxApiExtensions/Controllers/Client/Room/RoomsSendMessageController.cs
@@ -70,4 +70,4 @@ public class RoomsSendMessageController(ILogger<LoginController> logger, UserCon
             EventId = "$" + string.Join("", Random.Shared.GetItems("abcdefghijklmnopqrstuvwxyzABCDEFGHIJLKMNOPQRSTUVWXYZ0123456789".ToCharArray(), 100))
         });
     }
-}
\ No newline at end of file
+}
diff --git a/MxApiExtensions/Controllers/Client/SyncController.cs b/MxApiExtensions/Controllers/Client/SyncController.cs
index 615502b..3a759fc 100644
--- a/MxApiExtensions/Controllers/Client/SyncController.cs
+++ b/MxApiExtensions/Controllers/Client/SyncController.cs
@@ -291,4 +291,4 @@ public class SyncController(ILogger<SyncController> logger, MxApiExtensionsConfi
         syncState.SyncQueue.Enqueue(syncResponse);
         // _roomDataSemaphore.Release();
     }
-}
\ No newline at end of file
+}
diff --git a/MxApiExtensions/Controllers/Extensions/DebugController.cs b/MxApiExtensions/Controllers/Extensions/DebugController.cs
index 0a54481..6f87e51 100644
--- a/MxApiExtensions/Controllers/Extensions/DebugController.cs
+++ b/MxApiExtensions/Controllers/Extensions/DebugController.cs
@@ -46,4 +46,4 @@ public class DebugController(ILogger<ProxyConfigurationController> logger, MxApi
             UserContextService.UserContextStore
         };
     }
-}
\ No newline at end of file
+}
diff --git a/MxApiExtensions/Controllers/Extensions/JoinedRoomListController.cs b/MxApiExtensions/Controllers/Extensions/JoinedRoomListController.cs
index 9383390..07420d7 100644
--- a/MxApiExtensions/Controllers/Extensions/JoinedRoomListController.cs
+++ b/MxApiExtensions/Controllers/Extensions/JoinedRoomListController.cs
@@ -56,11 +56,11 @@ public class JoinedRoomListController : ControllerBase {
 
         if (hs is not null) {
             Response.ContentType = "application/json";
-            Response.Headers.Add("Cache-Control", "public, max-age=60");
-            Response.Headers.Add("Expires", DateTime.Now.AddMinutes(1).ToString("R"));
-            Response.Headers.Add("Last-Modified", DateTime.Now.ToString("R"));
-            Response.Headers.Add("X-Matrix-Server", hs.ServerName);
-            Response.Headers.Add("X-Matrix-User", hs.UserId);
+            Response.Headers.Append("Cache-Control", "public, max-age=60");
+            Response.Headers.Append("Expires", DateTime.Now.AddMinutes(1).ToString("R"));
+            Response.Headers.Append("Last-Modified", DateTime.Now.ToString("R"));
+            Response.Headers.Append("X-Matrix-Server", hs.ServerName);
+            Response.Headers.Append("X-Matrix-User", hs.UserId);
             // await Response.StartAsync();
 
             var cachedRooms = _roomInfoCache
@@ -99,8 +99,8 @@ public class JoinedRoomListController : ControllerBase {
             result.StateCount++;
             if (@event.Type != "m.room.member") result.RoomState.Add(@event);
             else {
-                if(!result.MemberCounts.ContainsKey((@event.TypedContent as RoomMemberEventContent)?.Membership)) result.MemberCounts.Add((@event.TypedContent as RoomMemberEventContent)?.Membership, 0);
-                    result.MemberCounts[(@event.TypedContent as RoomMemberEventContent)?.Membership]++;
+                if (!result.MemberCounts.ContainsKey((@event.TypedContent as RoomMemberEventContent)?.Membership)) result.MemberCounts.Add((@event.TypedContent as RoomMemberEventContent)?.Membership, 0);
+                result.MemberCounts[(@event.TypedContent as RoomMemberEventContent)?.Membership]++;
             }
         }
 
@@ -119,7 +119,7 @@ public class JoinedRoomListController : ControllerBase {
     [HttpGet("joined_rooms_with_info_cache")]
     public async Task<object> GetRoomInfoCache() {
         var mxid = await _authenticationService.GetMxidFromToken();
-        if(!_config.Admins.Contains(mxid)) {
+        if (!_config.Admins.Contains(mxid)) {
             Response.StatusCode = StatusCodes.Status403Forbidden;
             Response.ContentType = "application/json";
 
diff --git a/MxApiExtensions/Controllers/Extensions/ProxyConfigurationController.cs b/MxApiExtensions/Controllers/Extensions/ProxyConfigurationController.cs
index 0dcc3bb..b9d7e84 100644
--- a/MxApiExtensions/Controllers/Extensions/ProxyConfigurationController.cs
+++ b/MxApiExtensions/Controllers/Extensions/ProxyConfigurationController.cs
@@ -24,7 +24,7 @@ public class ProxyConfigurationController : ControllerBase {
     [HttpGet("proxy_config")]
     public async Task<MxApiExtensionsConfiguration> GetConfig() {
         var mxid = await _authenticationService.GetMxidFromToken();
-        if(!_config.Admins.Contains(mxid)) {
+        if (!_config.Admins.Contains(mxid)) {
             _logger.LogWarning("Got proxy config request for {user}, but they are not an admin", mxid);
             Response.StatusCode = StatusCodes.Status403Forbidden;
             Response.ContentType = "application/json";
diff --git a/MxApiExtensions/Controllers/Other/GenericProxyController.cs b/MxApiExtensions/Controllers/Other/GenericProxyController.cs
index 36ceab7..26c6371 100644
--- a/MxApiExtensions/Controllers/Other/GenericProxyController.cs
+++ b/MxApiExtensions/Controllers/Other/GenericProxyController.cs
@@ -188,4 +188,4 @@ public class GenericController(ILogger<GenericController> logger, MxApiExtension
             await Response.CompleteAsync();
         }
     }
-}
\ No newline at end of file
+}
diff --git a/MxApiExtensions/Controllers/Other/MediaProxyController.cs b/MxApiExtensions/Controllers/Other/MediaProxyController.cs
index d4c4ea0..7dea73b 100644
--- a/MxApiExtensions/Controllers/Other/MediaProxyController.cs
+++ b/MxApiExtensions/Controllers/Other/MediaProxyController.cs
@@ -21,7 +21,7 @@ public class MediaProxyController(ILogger<GenericController> logger, MxApiExtens
 
     private static Dictionary<string, MediaCacheEntry> _mediaCache = new();
     private static SemaphoreSlim _semaphore = new(1, 1);
-    
+
     [HttpGet("/_matrix/media/{_}/download/{serverName}/{mediaId}")]
     public async Task ProxyMedia(string? _, string serverName, string mediaId) {
         try {
@@ -34,13 +34,13 @@ public class MediaProxyController(ILogger<GenericController> logger, MxApiExtens
                 List<RemoteHomeserver> FeasibleHomeservers = new();
                 {
                     var a = await authenticatedHomeserverProviderService.TryGetRemoteHomeserver();
-                    if(a is not null)
+                    if (a is not null)
                         FeasibleHomeservers.Add(a);
 
                     if (a is AuthenticatedHomeserverGeneric ahg) {
                         var rooms = await ahg.GetJoinedRooms();
                         foreach (var room in rooms) {
-                            var ahs = (await room.GetMembersByHomeserverAsync()).Keys.Select(x=>x.ToString()).ToList();
+                            var ahs = (await room.GetMembersByHomeserverAsync()).Keys.Select(x => x.ToString()).ToList();
                             foreach (var ah in ahs) {
                                 try {
                                     if (!FeasibleHomeservers.Any(x => x.BaseUrl == ah)) {
@@ -52,19 +52,19 @@ public class MediaProxyController(ILogger<GenericController> logger, MxApiExtens
                         }
                     }
                 }
-                
+
                 FeasibleHomeservers.Add(await hsProvider.GetRemoteHomeserver(serverName));
-                
-                
+
+
                 foreach (var homeserver in FeasibleHomeservers) {
                     var resp = await homeserver.ClientHttpClient.GetAsync($"{Request.Path}");
-                    if(!resp.IsSuccessStatusCode) continue;
+                    if (!resp.IsSuccessStatusCode) continue;
                     entry.ContentType = resp.Content.Headers.ContentType?.ToString() ?? "application/json";
                     entry.Data = await resp.Content.ReadAsByteArrayAsync();
-                    if (entry.Data is not { Length: >0 }) throw new NullReferenceException("No data received?");
+                    if (entry.Data is not { Length: > 0 }) throw new NullReferenceException("No data received?");
                     break;
                 }
-                if (entry.Data is not { Length: >0 }) throw new NullReferenceException("No data received from any homeserver?");
+                if (entry.Data is not { Length: > 0 }) throw new NullReferenceException("No data received from any homeserver?");
             }
             else if (_mediaCache[$"{serverName}/{mediaId}"].Data is not { Length: > 0 }) {
                 _mediaCache.Remove($"{serverName}/{mediaId}");
@@ -74,7 +74,7 @@ public class MediaProxyController(ILogger<GenericController> logger, MxApiExtens
             else entry = _mediaCache[$"{serverName}/{mediaId}"];
             if (entry.Data is null) throw new NullReferenceException("No data?");
             _semaphore.Release();
-            
+
             Response.StatusCode = 200;
             Response.ContentType = entry.ContentType;
             await Response.StartAsync();