about summary refs log tree commit diff
path: root/MatrixRoomUtils.Core/Extensions
diff options
context:
space:
mode:
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