diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-09-29 19:38:00 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-09-29 19:38:00 +0200 |
commit | 46df5b8e335754f1582fc4d41d9546808ed8ee66 (patch) | |
tree | 29fed832bed495f1bd233c37275cb560c19f34cf /LibMatrix/Helpers/SyncHelper.cs | |
parent | Add more stuff, add unit tests (diff) | |
download | LibMatrix-46df5b8e335754f1582fc4d41d9546808ed8ee66.tar.xz |
Unit tests, small refactors
Diffstat (limited to '')
-rw-r--r-- | LibMatrix/Helpers/SyncHelper.cs | 16 |
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>(); |