diff --git a/ferri-main/src/types_rewrite/convert.rs b/ferri-main/src/types_rewrite/convert.rs index 16ed63c..a4c869c 100644 --- a/ferri-main/src/types_rewrite/convert.rs +++ b/ferri-main/src/types_rewrite/convert.rs @@ -26,3 +26,36 @@ impl From for db::Actor { } } } + +impl From for api::Account { + fn from(val: db::User) -> api::Account { + api::Account { + id: val.id, + username: val.username, + acct: "FIXME_api::Account::acct".to_string(), + display_name: val.display_name, + + locked: false, + bot: false, + + created_at: "FIXME_api::Account::created_at".to_string(), + attribution_domains: vec![], + + note: "".to_string(), + url: "FIXME_api::Account::url".to_string(), + + avatar: "https://ferri.amy.mov/assets/pfp.png".to_string(), + avatar_static: "https://ferri.amy.mov/assets/pfp.png".to_string(), + header: "https://ferri.amy.mov/assets/pfp.png".to_string(), + header_static: "https://ferri.amy.mov/assets/pfp.png".to_string(), + + followers_count: 0, + following_count: 0, + statuses_count: 0, + last_status_at: "FIXME_api::Account::last_status_at".to_string(), + + emojis: vec![], + fields: vec![], + } + } +} diff --git a/ferri-main/src/types_rewrite/mod.rs b/ferri-main/src/types_rewrite/mod.rs index b1baa5a..4f023a9 100644 --- a/ferri-main/src/types_rewrite/mod.rs +++ b/ferri-main/src/types_rewrite/mod.rs @@ -18,6 +18,9 @@ pub enum ObjectContext { #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] pub struct ObjectUri(String); +#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] +pub struct ObjectUuid(String); + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] pub struct Object { #[serde(rename = "@context")] @@ -34,7 +37,15 @@ pub mod db { pub id: ObjectUri, pub inbox: String, pub outbox: String, - } + } + + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] + pub struct User { + pub id: ObjectUuid, + pub actor_id: ObjectUri, + pub username: String, + pub display_name: String + } } pub mod ap { @@ -49,6 +60,33 @@ pub mod ap { pub inbox: String, pub outbox: String, } + + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] + pub struct Person { + #[serde(flatten)] + pub obj: Object, + + pub following: String, + pub followers: String, + + pub summary: String, + pub inbox: String, + pub outbox: String, + + pub preferred_username: String, + pub name: String, + + pub public_key: Option, + } + + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] + pub struct UserKey { + pub id: String, + pub owner: String, + + #[serde(rename = "publicKeyPem")] + pub public_key: String, + } } pub mod api { @@ -58,6 +96,51 @@ pub mod api { // API will not really use actors so treat them as DB actors // until we require specificity pub type Actor = db::Actor; + + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] + pub struct Account { + pub id: ObjectUuid, + pub username: String, + pub acct: String, + pub display_name: String, + + pub locked: bool, + pub bot: bool, + + pub created_at: String, + pub attribution_domains: Vec, + + pub note: String, + pub url: String, + + pub avatar: String, + pub avatar_static: String, + pub header: String, + pub header_static: String, + + pub followers_count: i64, + pub following_count: i64, + pub statuses_count: i64, + pub last_status_at: String, + + pub emojis: Vec, + pub fields: Vec, + } + + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] + pub struct Emoji { + pub shortcode: String, + pub url: String, + pub static_url: String, + pub visible_in_picker: bool, + } + + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] + pub struct CustomField { + pub name: String, + pub value: String, + pub verified_at: Option, + } } #[cfg(test)] @@ -67,6 +150,7 @@ mod tests { #[test] fn ap_actor_to_db() { let domain = "https://example.com"; + let ap = ap::Actor { obj: Object { context: as_context(),