about summary refs log tree commit diff
path: root/LibMatrix/Helpers
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-29 19:38:00 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-29 19:38:00 +0200
commit46df5b8e335754f1582fc4d41d9546808ed8ee66 (patch)
tree29fed832bed495f1bd233c37275cb560c19f34cf /LibMatrix/Helpers
parentAdd more stuff, add unit tests (diff)
downloadLibMatrix-46df5b8e335754f1582fc4d41d9546808ed8ee66.tar.xz
Unit tests, small refactors
Diffstat (limited to 'LibMatrix/Helpers')
-rw-r--r--LibMatrix/Helpers/SyncHelper.cs16
1 files changed, 5 insertions, 11 deletions
diff --git a/LibMatrix/Helpers/SyncHelper.cs b/LibMatrix/Helpers/SyncHelper.cs
index 386fd4d..74972a1 100644
--- a/LibMatrix/Helpers/SyncHelper.cs
+++ b/LibMatrix/Helpers/SyncHelper.cs
@@ -16,10 +16,6 @@ public class SyncHelper(AuthenticatedHomeserverGeneric homeserver) {
         string? setPresence = "online",
         SyncFilter? filter = null,
         CancellationToken? cancellationToken = null) {
-        // var outFileName = "sync-" +
-        //                   (await storageService.CacheStorageProvider.GetAllKeysAsync()).Count(
-        //                       x => x.StartsWith("sync")) +
-        //                   ".json";
         var url = $"/_matrix/client/v3/sync?timeout={timeout}&set_presence={setPresence}";
         if (!string.IsNullOrWhiteSpace(since)) url += $"&since={since}";
         if (filter is not null) url += $"&filter={filter.ToJson(ignoreNull: true, indent: false)}";
@@ -28,19 +24,17 @@ public class SyncHelper(AuthenticatedHomeserverGeneric homeserver) {
         try {
             var req = await homeserver._httpClient.GetAsync(url, cancellationToken: cancellationToken ?? CancellationToken.None);
 
-            // var res = await JsonSerializer.DeserializeAsync<SyncResult>(await req.Content.ReadAsStreamAsync());
-
 #if DEBUG && false
-            var jsonObj = await req.Content.ReadFromJsonAsync<JsonElement>();
             try {
-                await _homeServer._httpClient.PostAsJsonAsync(
-                    "http://localhost:5116/validate/" + typeof(SyncResult).AssemblyQualifiedName, jsonObj);
+                await homeserver._httpClient.PostAsync(
+                    "http://localhost:5116/validate/" + typeof(SyncResult).AssemblyQualifiedName,
+                    new StreamContent(await req.Content.ReadAsStreamAsync()));
             }
+
             catch (Exception e) {
                 Console.WriteLine("[!!] Checking sync response failed: " + e);
             }
-
-            var res = jsonObj.Deserialize<SyncResult>();
+            var res = await req.Content.ReadFromJsonAsync<SyncResult>();
             return res;
 #else
             return await req.Content.ReadFromJsonAsync<SyncResult>();