about summary refs log tree commit diff
path: root/LibMatrix/Helpers/SyncHelper.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-19 07:20:34 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-19 07:20:34 +0200
commit0330ff6706a968400ca8fe2a3e3ccf6237a15566 (patch)
treef2ffe7b16050ea0cbd19aa08af48b67d12ec4848 /LibMatrix/Helpers/SyncHelper.cs
parentAdd profile updating (diff)
downloadLibMatrix-0330ff6706a968400ca8fe2a3e3ccf6237a15566.tar.xz
fix synchelper null check
Diffstat (limited to 'LibMatrix/Helpers/SyncHelper.cs')
-rw-r--r--LibMatrix/Helpers/SyncHelper.cs8
1 files changed, 6 insertions, 2 deletions
diff --git a/LibMatrix/Helpers/SyncHelper.cs b/LibMatrix/Helpers/SyncHelper.cs
index bfcd650..c6c5378 100644
--- a/LibMatrix/Helpers/SyncHelper.cs
+++ b/LibMatrix/Helpers/SyncHelper.cs
@@ -15,15 +15,19 @@ public class SyncHelper(AuthenticatedHomeserverGeneric homeserver, ILogger? logg
     public bool FullState { get; set; } = false;
 
     public bool IsInitialSync { get; set; } = true;
-
+    
     public async Task<SyncResponse?> SyncAsync(CancellationToken? cancellationToken = null) {
+        if (homeserver is null) {
+            Console.WriteLine("Null passed as homeserver for SyncHelper!");
+            throw new ArgumentNullException("Null passed as homeserver for SyncHelper!");
+        }
         var url = $"/_matrix/client/v3/sync?timeout={Timeout}&set_presence={SetPresence}&full_state={(FullState ? "true" : "false")}";
         if (!string.IsNullOrWhiteSpace(Since)) url += $"&since={Since}";
         if (Filter is not null) url += $"&filter={Filter.ToJson(ignoreNull: true, indent: false)}";
         // Console.WriteLine("Calling: " + url);
         logger?.LogInformation("SyncHelper: Calling: {}", url);
         try {
-            return await homeserver._httpClient.GetFromJsonAsync<SyncResponse>(url, cancellationToken: cancellationToken ?? CancellationToken.None);
+            return await homeserver?._httpClient?.GetFromJsonAsync<SyncResponse>(url, cancellationToken: cancellationToken ?? CancellationToken.None)!;
         }
         catch (TaskCanceledException) {
             Console.WriteLine("Sync cancelled!");