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/DeviceKeysUploadRequest.cs24
-rw-r--r--LibMatrix/Responses/SyncResponse.cs12
-rw-r--r--LibMatrix/Responses/UserDirectoryResponse.cs30
-rw-r--r--LibMatrix/Responses/UserProfileResponse.cs15
4 files changed, 77 insertions, 4 deletions
diff --git a/LibMatrix/Responses/DeviceKeysUploadRequest.cs b/LibMatrix/Responses/DeviceKeysUploadRequest.cs
new file mode 100644

index 0000000..c93c4c6 --- /dev/null +++ b/LibMatrix/Responses/DeviceKeysUploadRequest.cs
@@ -0,0 +1,24 @@ +using System.Text.Json.Serialization; + +namespace LibMatrix.Responses; + +public class DeviceKeysUploadRequest { + [JsonPropertyName("device_keys")] + public DeviceKeysSchema DeviceKeys { get; set; } + + + [JsonPropertyName("one_time_keys")] + public Dictionary<string, OneTimeKey> OneTimeKeys { get; set; } + + public class DeviceKeysSchema { + [JsonPropertyName("algorithms")] + public List<string> Algorithms { get; set; } + } + public class OneTimeKey { + [JsonPropertyName("key")] + public string Key { get; set; } + + [JsonPropertyName("signatures")] + public Dictionary<string, Dictionary<string, string>> Signatures { get; set; } + } +} \ No newline at end of file diff --git a/LibMatrix/Responses/SyncResponse.cs b/LibMatrix/Responses/SyncResponse.cs
index 2d3d3f8..a4391b7 100644 --- a/LibMatrix/Responses/SyncResponse.cs +++ b/LibMatrix/Responses/SyncResponse.cs
@@ -39,6 +39,10 @@ public class SyncResponse { } // supporting classes + public class PresenceDataStructure { + [JsonPropertyName("events")] + public List<StateEventResponse>? Events { get; set; } + } public class RoomsDataStructure { [JsonPropertyName("join")] @@ -86,7 +90,7 @@ public class SyncResponse { [JsonPropertyName("summary")] public SummaryDataStructure? Summary { get; set; } - public class TimelineDataStructure { + public class TimelineDataStructure : EventList { public TimelineDataStructure() { } public TimelineDataStructure(List<StateEventResponse>? events, bool? limited) { @@ -94,8 +98,8 @@ public class SyncResponse { Limited = limited; } - [JsonPropertyName("events")] - public List<StateEventResponse>? Events { get; set; } + // [JsonPropertyName("events")] + // public List<StateEventResponse>? Events { get; set; } [JsonPropertyName("prev_batch")] public string? PrevBatch { get; set; } @@ -140,4 +144,4 @@ public class SyncResponse { Rooms?.Leave?.Values?.Max(x => x.Timeline?.Events?.Max(y => y.OriginServerTs)) ?? 0 ]).Max(); } -} \ No newline at end of file +} diff --git a/LibMatrix/Responses/UserDirectoryResponse.cs b/LibMatrix/Responses/UserDirectoryResponse.cs new file mode 100644
index 0000000..13235d9 --- /dev/null +++ b/LibMatrix/Responses/UserDirectoryResponse.cs
@@ -0,0 +1,30 @@ +using System.Text.Json.Serialization; + +namespace LibMatrix.Responses; + +public class UserDirectoryResponse { + [JsonPropertyName("limited")] + public bool Limited { get; set; } + + [JsonPropertyName("results")] + public List<UserDirectoryResult> Results { get; set; } + + public class UserDirectoryResult { + [JsonPropertyName("avatar_url")] + public string? AvatarUrl { get; set; } + + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + [JsonPropertyName("user_id")] + public string UserId { get; set; } + } +} + +public class UserDirectoryRequest { + [JsonPropertyName("search_term")] + public string SearchTerm { get; set; } + + [JsonPropertyName("limit")] + public int? Limit { get; set; } +} \ No newline at end of file diff --git a/LibMatrix/Responses/UserProfileResponse.cs b/LibMatrix/Responses/UserProfileResponse.cs
index 6c9380f..30e4c32 100644 --- a/LibMatrix/Responses/UserProfileResponse.cs +++ b/LibMatrix/Responses/UserProfileResponse.cs
@@ -1,3 +1,4 @@ +using System.Text.Json; using System.Text.Json.Serialization; namespace LibMatrix.Responses; @@ -8,4 +9,18 @@ public class UserProfileResponse { [JsonPropertyName("displayname")] public string? DisplayName { get; set; } + + // MSC 4133 - Extending User Profile API with Key:Value pairs + [JsonExtensionData] + public Dictionary<string, JsonElement>? CustomKeys { get; set; } + + public JsonElement? this[string key] { + get => CustomKeys?[key]; + set { + if (value is null) + CustomKeys?.Remove(key); + else + (CustomKeys ??= [])[key] = value.Value; + } + } } \ No newline at end of file