module util; import asdf; struct JsonObject { import std.conv: to; string data; SerdeException deserializeFromAsdf(Asdf data) { this.data = data.to!string; return null; } void serialize(S)(ref S serializer) { try serializer.sink.putSmallEscaped(data.parseJson.to!string); catch (Exception) serializer.sink.putSmallEscaped("{}"); } } struct Sync { struct StrippedStateEvent { JsonObject content; string sender, state_key, type; } struct Unsigned { int age; string membership, transaction_id; } struct Rooms { struct Invited { struct IS { StrippedStateEvent[] events; } IS invite_state; } struct Joined { struct Timeline { struct EventWithoutRoomID { JsonObject content; string event_id; ulong origin_server_ts; @serdeOptional string sender, state_key, type; // Unsigned unsigned; } EventWithoutRoomID[] events; bool limited; string prev_batch; } struct UNC { int highlight_count; int notification_count; } Timeline timeline; UNC unread_notifications; } @serdeOptional Invited[string] invite; @serdeOptional Joined[string] join; } @serdeOptional Rooms rooms; string next_batch; } // EVENTS struct MSG { string body; @serdeOptional @serdeIgnoreDefault string formatted_body; string msgtype = "m.notice"; @serdeOptional string format = "org.matrix.custom.html"; }