about summary refs log tree commit diff
path: root/LibMatrix/Responses
diff options
context:
space:
mode:
Diffstat (limited to 'LibMatrix/Responses')
-rw-r--r--LibMatrix/Responses/CreateRoomRequest.cs1
-rw-r--r--LibMatrix/Responses/LoginResponse.cs2
-rw-r--r--LibMatrix/Responses/StateEventResponse.cs52
-rw-r--r--LibMatrix/Responses/SyncResponse.cs118
4 files changed, 120 insertions, 53 deletions
diff --git a/LibMatrix/Responses/CreateRoomRequest.cs b/LibMatrix/Responses/CreateRoomRequest.cs
index 511b3da..1ad590f 100644
--- a/LibMatrix/Responses/CreateRoomRequest.cs
+++ b/LibMatrix/Responses/CreateRoomRequest.cs
@@ -2,6 +2,7 @@ using System.Reflection;
 using System.Text.Json.Nodes;
 using System.Text.Json.Serialization;
 using System.Text.RegularExpressions;
+using LibMatrix.EventTypes;
 using LibMatrix.EventTypes.Spec.State;
 using LibMatrix.Helpers;
 using LibMatrix.Homeservers;
diff --git a/LibMatrix/Responses/LoginResponse.cs b/LibMatrix/Responses/LoginResponse.cs
index eb53c0a..07b1601 100644
--- a/LibMatrix/Responses/LoginResponse.cs
+++ b/LibMatrix/Responses/LoginResponse.cs
@@ -23,7 +23,7 @@ public class LoginResponse {
     public string UserId { get; set; } = null!;
 
     public async Task<AuthenticatedHomeserverGeneric> GetAuthenticatedHomeserver(string? proxy = null) {
-        return new AuthenticatedHomeserverGeneric(proxy ?? await new HomeserverResolverService().ResolveHomeserverFromWellKnown(Homeserver), AccessToken);
+        return await AuthenticatedHomeserverGeneric.Create<AuthenticatedHomeserverGeneric>(proxy ?? await new HomeserverResolverService().ResolveHomeserverFromWellKnown(Homeserver), AccessToken);
     }
 }
 public class LoginRequest {
diff --git a/LibMatrix/Responses/StateEventResponse.cs b/LibMatrix/Responses/StateEventResponse.cs
deleted file mode 100644
index 7ca6bab..0000000
--- a/LibMatrix/Responses/StateEventResponse.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System.Text.Json.Nodes;
-using System.Text.Json.Serialization;
-
-namespace LibMatrix.Responses;
-
-public class StateEventResponse : StateEvent {
-    [JsonPropertyName("origin_server_ts")]
-    public ulong OriginServerTs { get; set; }
-
-    [JsonPropertyName("room_id")]
-    public string RoomId { get; set; }
-
-    [JsonPropertyName("sender")]
-    public string Sender { get; set; }
-
-    [JsonPropertyName("unsigned")]
-    public UnsignedData? Unsigned { get; set; }
-
-    [JsonPropertyName("event_id")]
-    public string EventId { get; set; }
-
-    [JsonPropertyName("user_id")]
-    public string UserId { get; set; }
-
-    [JsonPropertyName("replaces_state")]
-    public new string ReplacesState { get; set; }
-
-    public class UnsignedData {
-        [JsonPropertyName("age")]
-        public ulong? Age { get; set; }
-
-        [JsonPropertyName("redacted_because")]
-        public object? RedactedBecause { get; set; }
-
-        [JsonPropertyName("transaction_id")]
-        public string? TransactionId { get; set; }
-
-        [JsonPropertyName("replaces_state")]
-        public string? ReplacesState { get; set; }
-
-        [JsonPropertyName("prev_sender")]
-        public string? PrevSender { get; set; }
-
-        [JsonPropertyName("prev_content")]
-        public JsonObject? PrevContent { get; set; }
-    }
-}
-
-public class ChunkedStateEventResponse {
-    [JsonPropertyName("chunk")]
-    public List<StateEventResponse>? Chunk { get; set; }
-}
diff --git a/LibMatrix/Responses/SyncResponse.cs b/LibMatrix/Responses/SyncResponse.cs
new file mode 100644
index 0000000..39cb38f
--- /dev/null
+++ b/LibMatrix/Responses/SyncResponse.cs
@@ -0,0 +1,118 @@
+using System.Text.Json.Serialization;
+using LibMatrix.Helpers;
+
+namespace LibMatrix.Responses;
+
+public class SyncResponse {
+    [JsonPropertyName("next_batch")]
+    public string NextBatch { get; set; } = null!;
+
+    [JsonPropertyName("account_data")]
+    public EventList? AccountData { get; set; }
+
+    [JsonPropertyName("presence")]
+    public PresenceDataStructure? Presence { get; set; }
+
+    [JsonPropertyName("device_one_time_keys_count")]
+    public Dictionary<string, int>? DeviceOneTimeKeysCount { get; set; } = null!;
+
+    [JsonPropertyName("rooms")]
+    public RoomsDataStructure? Rooms { get; set; }
+
+    [JsonPropertyName("to_device")]
+    public EventList? ToDevice { get; set; }
+
+    [JsonPropertyName("device_lists")]
+    public DeviceListsDataStructure? DeviceLists { get; set; }
+
+    public class DeviceListsDataStructure {
+        [JsonPropertyName("changed")]
+        public List<string>? Changed { get; set; }
+
+        [JsonPropertyName("left")]
+        public List<string>? Left { get; set; }
+    }
+
+    // supporting classes
+    public class PresenceDataStructure {
+        [JsonPropertyName("events")]
+        public List<StateEventResponse> Events { get; set; } = new();
+    }
+
+    public class RoomsDataStructure {
+        [JsonPropertyName("join")]
+        public Dictionary<string, JoinedRoomDataStructure>? Join { get; set; }
+
+        [JsonPropertyName("invite")]
+        public Dictionary<string, InvitedRoomDataStructure>? Invite { get; set; }
+
+        [JsonPropertyName("leave")]
+        public Dictionary<string, LeftRoomDataStructure>? Leave { get; set; }
+
+        public class LeftRoomDataStructure {
+            [JsonPropertyName("account_data")]
+            public EventList AccountData { get; set; }
+
+            [JsonPropertyName("timeline")]
+            public JoinedRoomDataStructure.TimelineDataStructure? Timeline { get; set; }
+
+            [JsonPropertyName("state")]
+            public EventList State { get; set; }
+        }
+
+        public class JoinedRoomDataStructure {
+            [JsonPropertyName("timeline")]
+            public TimelineDataStructure? Timeline { get; set; }
+
+            [JsonPropertyName("state")]
+            public EventList? State { get; set; }
+
+            [JsonPropertyName("account_data")]
+            public EventList? AccountData { get; set; }
+
+            [JsonPropertyName("ephemeral")]
+            public EventList? Ephemeral { get; set; }
+
+            [JsonPropertyName("unread_notifications")]
+            public UnreadNotificationsDataStructure? UnreadNotifications { get; set; }
+
+            [JsonPropertyName("summary")]
+            public SummaryDataStructure? Summary { get; set; }
+
+            public class TimelineDataStructure {
+                [JsonPropertyName("events")]
+                public List<StateEventResponse>? Events { get; set; }
+
+                [JsonPropertyName("prev_batch")]
+                public string? PrevBatch { get; set; }
+
+                [JsonPropertyName("limited")]
+                public bool? Limited { get; set; }
+            }
+
+            public class UnreadNotificationsDataStructure {
+                [JsonPropertyName("notification_count")]
+                public int NotificationCount { get; set; }
+
+                [JsonPropertyName("highlight_count")]
+                public int HighlightCount { get; set; }
+            }
+
+            public class SummaryDataStructure {
+                [JsonPropertyName("m.heroes")]
+                public List<string> Heroes { get; set; }
+
+                [JsonPropertyName("m.invited_member_count")]
+                public int InvitedMemberCount { get; set; }
+
+                [JsonPropertyName("m.joined_member_count")]
+                public int JoinedMemberCount { get; set; }
+            }
+        }
+
+        public class InvitedRoomDataStructure {
+            [JsonPropertyName("invite_state")]
+            public EventList? InviteState { get; set; }
+        }
+    }
+}