170 lines
3.8 KiB
Rust
170 lines
3.8 KiB
Rust
use serde::Deserialize;
|
|
use std::collections::HashMap;
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct SyncResponse {
|
|
pub next_batch: String,
|
|
pub rooms: Option<Rooms>,
|
|
pub presence: Option<Presence>,
|
|
pub account_data: Option<AccountData>,
|
|
pub to_device: Option<ToDevice>,
|
|
pub device_lists: Option<DeviceLists>,
|
|
pub device_one_time_keys_count: Option<HashMap<String, u64>>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct Rooms {
|
|
pub join: Option<HashMap<String, JoinedRoom>>,
|
|
pub invite: Option<HashMap<String, InvitedRoom>>,
|
|
pub leave: Option<HashMap<String, LeftRoom>>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct JoinedRoom {
|
|
pub summary: Option<RoomSummary>,
|
|
pub state: Option<State>,
|
|
pub timeline: Option<Timeline>,
|
|
pub ephemeral: Option<Ephemeral>,
|
|
pub account_date: Option<AccountData>,
|
|
pub unread_notifications: Option<UnreadNotificationCounts>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct RoomSummary {
|
|
#[serde(rename = "m.heroes")]
|
|
pub heros: Option<Vec<String>>,
|
|
#[serde(rename = "m.joined_member_count")]
|
|
pub joined_member_count: Option<u64>,
|
|
#[serde(rename = "m.invited_member_count")]
|
|
pub invited_member_count: Option<u64>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct State {
|
|
pub events: Option<StateEvents>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct StateEvents {
|
|
pub content: serde_json::value::Value, // This is an json object
|
|
pub r#type: String,
|
|
pub event_id: String,
|
|
pub sender: String,
|
|
pub origin_server_ts: u64,
|
|
pub unsigned: Option<UnsignedData>,
|
|
pub prev_content: Option<EventContent>,
|
|
pub state_key: String,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct UnsignedData {
|
|
pub age: Option<u64>,
|
|
pub redacted_because: Option<Event>,
|
|
pub transaction_id: Option<String>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct Event {
|
|
pub content: serde_json::value::Value, // Json object
|
|
pub r#type: String,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct EventContent {
|
|
pub avatar_url: Option<String>,
|
|
pub displayname: Option<String>, //type is string or null????
|
|
pub membership: Membership,
|
|
pub state_key: String,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum Membership {
|
|
Invite,
|
|
Join,
|
|
Knock,
|
|
Leave,
|
|
Ban,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct Timeline {
|
|
pub events: Option<Vec<RoomEvent>>,
|
|
pub limited: Option<bool>,
|
|
pub prev_batch: Option<String>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct RoomEvent {
|
|
pub content: String,
|
|
pub r#type: String,
|
|
pub event_id: String,
|
|
pub sender: String,
|
|
pub origin_server_ts: u64,
|
|
pub unsigned: Option<UnsignedData>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct Ephemeral {
|
|
pub events: Option<Vec<Event>>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct AccountData {
|
|
pub events: Option<Vec<Event>>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct UnreadNotificationCounts {
|
|
pub highlight_count: Option<u64>,
|
|
pub notification_count: Option<u64>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct InvitedRoom {
|
|
pub invite_state: Option<InviteState>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct InviteState {
|
|
pub events: Option<Vec<StrippedState>>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct StrippedState {
|
|
pub content: EventContent,
|
|
pub state_key: String,
|
|
pub r#type: String,
|
|
pub sender: String,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct LeftRoom {
|
|
pub state: Option<State>,
|
|
pub timeline: Option<Timeline>,
|
|
pub account_data: Option<AccountData>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct Presence {
|
|
pub events: Option<Vec<Event>>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct ToDevice {
|
|
pub events: Option<Vec<ToDeviceEvent>>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct ToDeviceEvent {
|
|
pub content: Option<EventContent>,
|
|
pub sender: Option<String>,
|
|
pub r#type: Option<String>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct DeviceLists {
|
|
pub changed: Option<Vec<String>>,
|
|
pub left: Option<Vec<String>>,
|
|
}
|