5 files changed, 118 insertions, 0 deletions
diff --git a/LibMatrix.Federation/FederationTypes/FederationBackfillResponse.cs b/LibMatrix.Federation/FederationTypes/FederationBackfillResponse.cs
new file mode 100644
index 0000000..0fe72bd
--- /dev/null
+++ b/LibMatrix.Federation/FederationTypes/FederationBackfillResponse.cs
@@ -0,0 +1,14 @@
+using System.Text.Json.Serialization;
+
+namespace LibMatrix.Federation.FederationTypes;
+
+public class FederationBackfillResponse {
+ [JsonPropertyName("origin")]
+ public required string Origin { get; set; }
+
+ [JsonPropertyName("origin_server_ts")]
+ public required long OriginServerTs { get; set; }
+
+ [JsonPropertyName("pdus")]
+ public required List<SignedFederationEvent> Pdus { get; set; }
+}
\ No newline at end of file
diff --git a/LibMatrix.Federation/FederationTypes/FederationEvent.cs b/LibMatrix.Federation/FederationTypes/FederationEvent.cs
new file mode 100644
index 0000000..05bdcc9
--- /dev/null
+++ b/LibMatrix.Federation/FederationTypes/FederationEvent.cs
@@ -0,0 +1,30 @@
+using System.Text.Json.Serialization;
+
+namespace LibMatrix.Federation.FederationTypes;
+
+public class FederationEvent : MatrixEventResponse {
+ [JsonPropertyName("auth_events")]
+ public required List<string> AuthEvents { get; set; } = [];
+
+ [JsonPropertyName("prev_events")]
+ public required List<string> PrevEvents { get; set; } = [];
+
+ [JsonPropertyName("depth")]
+ public required int Depth { get; set; }
+}
+
+public class SignedFederationEvent : FederationEvent {
+ [JsonPropertyName("signatures")]
+ public required Dictionary<string, Dictionary<string, string>> Signatures { get; set; } = new();
+
+ [JsonPropertyName("hashes")]
+ public required Dictionary<string, string> Hashes { get; set; } = new();
+}
+
+public class FederationEphemeralEvent {
+ [JsonPropertyName("edu_type")]
+ public required string Type { get; set; }
+
+ [JsonPropertyName("content")]
+ public required Dictionary<string, object> Content { get; set; } = new();
+}
\ No newline at end of file
diff --git a/LibMatrix.Federation/FederationTypes/FederationGetMissingEventsRequest.cs b/LibMatrix.Federation/FederationTypes/FederationGetMissingEventsRequest.cs
new file mode 100644
index 0000000..f43dd49
--- /dev/null
+++ b/LibMatrix.Federation/FederationTypes/FederationGetMissingEventsRequest.cs
@@ -0,0 +1,34 @@
+using System.Text.Json.Serialization;
+
+namespace LibMatrix.Federation.FederationTypes;
+
+public class FederationGetMissingEventsRequest {
+ /// <summary>
+ /// Latest event IDs we already have (aka earliest to return)
+ /// </summary>
+ [JsonPropertyName("earliest_events")]
+ public required List<string> EarliestEvents { get; set; }
+
+ /// <summary>
+ /// Events we want to get events before
+ /// </summary>
+ [JsonPropertyName("latest_events")]
+ public required List<string> LatestEvents { get; set; }
+
+ /// <summary>
+ /// 10 by default
+ /// </summary>
+ [JsonPropertyName("limit")]
+ public int Limit { get; set; }
+
+ /// <summary>
+ /// 0 by default
+ /// </summary>
+ [JsonPropertyName("min_depth")]
+ public long MinDepth { get; set; }
+}
+
+public class FederationGetMissingEventsResponse {
+ [JsonPropertyName("events")]
+ public required List<SignedFederationEvent> Events { get; set; }
+}
\ No newline at end of file
diff --git a/LibMatrix.Federation/FederationTypes/FederationTransaction.cs b/LibMatrix.Federation/FederationTypes/FederationTransaction.cs
new file mode 100644
index 0000000..0581a08
--- /dev/null
+++ b/LibMatrix.Federation/FederationTypes/FederationTransaction.cs
@@ -0,0 +1,26 @@
+using System.Text.Json.Serialization;
+
+namespace LibMatrix.Federation.FederationTypes;
+
+/// <summary>
+/// This only covers v12 rooms for now?
+/// </summary>
+public class FederationTransaction {
+ /// <summary>
+ /// Up to 100 EDUs per transaction
+ /// </summary>
+ [JsonPropertyName("edus")]
+ public List<FederationEvent>? EphemeralEvents { get; set; }
+
+ [JsonPropertyName("origin")]
+ public required string Origin { get; set; }
+
+ [JsonPropertyName("origin_server_ts")]
+ public required long OriginServerTs { get; set; }
+
+ /// <summary>
+ /// Up to 50 PDUs per transaction
+ /// </summary>
+ [JsonPropertyName("pdus")]
+ public List<SignedFederationEvent>? PersistentEvents { get; set; }
+}
\ No newline at end of file
diff --git a/LibMatrix.Federation/FederationTypes/RoomInvite.cs b/LibMatrix.Federation/FederationTypes/RoomInvite.cs
new file mode 100644
index 0000000..dc550f3
--- /dev/null
+++ b/LibMatrix.Federation/FederationTypes/RoomInvite.cs
@@ -0,0 +1,14 @@
+using System.Text.Json.Serialization;
+
+namespace LibMatrix.Federation.FederationTypes;
+
+public class RoomInvite {
+ [JsonPropertyName("event")]
+ public required SignedFederationEvent Event { get; set; }
+
+ [JsonPropertyName("invite_room_state")]
+ public required List<MatrixEventResponse> InviteRoomState { get; set; } = [];
+
+ [JsonPropertyName("room_version")]
+ public required string RoomVersion { get; set; }
+}
\ No newline at end of file
|