about summary refs log tree commit diff
path: root/MatrixRoomUtils.Core/Extensions
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-05-03 18:40:53 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-05-03 18:40:53 +0200
commit3d3edeae16252a311704b390cfad6faa435a8b84 (patch)
tree34974194435fbe9789de5140ef9a9c0ddb834c74 /MatrixRoomUtils.Core/Extensions
parentAdd policy room discovery ,add room state viewer (diff)
downloadMatrixUtils-3d3edeae16252a311704b390cfad6faa435a8b84.tar.xz
Refactor
Diffstat (limited to 'MatrixRoomUtils.Core/Extensions')
-rw-r--r--MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs19
-rw-r--r--MatrixRoomUtils.Core/Extensions/StringExtensions.cs2
2 files changed, 20 insertions, 1 deletions
diff --git a/MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs b/MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs
new file mode 100644

index 0000000..66a5133 --- /dev/null +++ b/MatrixRoomUtils.Core/Extensions/HttpClientExtensions.cs
@@ -0,0 +1,19 @@ +namespace MatrixRoomUtils.Extensions; + +public static class HttpClientExtensions +{ + public static async Task<bool> CheckSuccessStatus(this HttpClient hc, string url) + { + //cors causes failure, try to catch + try + { + var resp = await hc.GetAsync(url); + return resp.IsSuccessStatusCode; + } + catch (Exception e) + { + Console.WriteLine($"Failed to check success status: {e.Message}"); + return false; + } + } +} \ No newline at end of file diff --git a/MatrixRoomUtils.Core/Extensions/StringExtensions.cs b/MatrixRoomUtils.Core/Extensions/StringExtensions.cs
index e02f0b9..27d8265 100644 --- a/MatrixRoomUtils.Core/Extensions/StringExtensions.cs +++ b/MatrixRoomUtils.Core/Extensions/StringExtensions.cs
@@ -11,7 +11,7 @@ public static class StringExtensions var server = MxcUrl.Split('/')[2]; var mediaId = MxcUrl.Split('/')[3]; - return $"{await MatrixAccount.ResolveHomeserverFromWellKnown(server)}/_matrix/media/v3/download/{server}/{mediaId}"; + return $"{await MatrixAuth.ResolveHomeserverFromWellKnown(server)}/_matrix/media/v3/download/{server}/{mediaId}"; } } \ No newline at end of file