diff --git a/src/models/homeserver/bookmark.rs b/src/models/homeserver/bookmark.rs new file mode 100644 index 00000000..0898c52b --- /dev/null +++ b/src/models/homeserver/bookmark.rs @@ -0,0 +1,13 @@ +use serde::{Deserialize, Serialize}; + +/// Represents raw homeserver bookmark with id +/// URI: /pub/pubky.app/bookmarks/:URI_BOOKMARKED_OBJECT +/// +/// Example URI: +/// +/// `/pub/pubky.app/bookmarks/pxnu33x7jtpx9ar1ytsi4yxbp6a5o36gwhffs8zoxmbuptici1jy/pub/pubky.app/posts/2ZKGWXZ44J300/cool` +/// +#[derive(Serialize, Deserialize, Default)] +pub struct HomeserverBookmark { + pub created_at: i64, +} diff --git a/src/models/homeserver/follow.rs b/src/models/homeserver/follow.rs new file mode 100644 index 00000000..25ea836f --- /dev/null +++ b/src/models/homeserver/follow.rs @@ -0,0 +1,13 @@ +use serde::{Deserialize, Serialize}; + +/// Represents raw homeserver follow object with timestamp +/// URI: /pub/pubky.app/follows/:user_id +/// +/// Example URI: +/// +/// `/pub/pubky.app/follows/pxnu33x7jtpx9ar1ytsi4yxbp6a5o36gwhffs8zoxmbuptici1jy`` +/// +#[derive(Serialize, Deserialize, Default)] +pub struct HomeserverFollow { + pub created_at: i64, +} diff --git a/src/models/homeserver/mod.rs b/src/models/homeserver/mod.rs index e153e1db..91a4ec03 100644 --- a/src/models/homeserver/mod.rs +++ b/src/models/homeserver/mod.rs @@ -1,4 +1,12 @@ -/// Raw schemas stored on homeserver. -pub mod user; +/// Raw schemas as stored on homeserver. +mod bookmark; +mod follow; +mod post; +mod tag; +mod user; +pub use bookmark::HomeserverBookmark; +pub use follow::HomeserverFollow; +pub use post::{HomeserverPost, PostKind}; +pub use tag::HomeserverTag; pub use user::{HomeserverUser, UserLink}; diff --git a/src/models/homeserver/post.rs b/src/models/homeserver/post.rs new file mode 100644 index 00000000..5f2342ec --- /dev/null +++ b/src/models/homeserver/post.rs @@ -0,0 +1,32 @@ +use serde::{Deserialize, Serialize}; +use utoipa::ToSchema; + +/// Represents the type of pubky-app posted data +/// Used primarily to best display the content in UI +#[derive(Serialize, Deserialize, ToSchema, Default)] +pub enum PostKind { + #[default] + Short, + Long, + Image, + Video, + Link, + File, +} + +/// Used primarily to best display the content in UI +#[derive(Serialize, Deserialize, Default)] +pub struct PostEmbed { + pub r#type: String, //e.g., "post", we have to define a type for this. + pub uri: String, +} + +/// Represents raw post in homeserver with content and kind +/// URI: /pub/pubky.app/posts/:post_id +/// Where post_id is CrockfordBase32 encoding of timestamp +#[derive(Serialize, Deserialize, Default)] +pub struct HomeserverPost { + pub content: String, + pub kind: PostKind, + pub embed: PostEmbed, +} diff --git a/src/models/homeserver/tag.rs b/src/models/homeserver/tag.rs new file mode 100644 index 00000000..4ba5f2b4 --- /dev/null +++ b/src/models/homeserver/tag.rs @@ -0,0 +1,13 @@ +use serde::{Deserialize, Serialize}; + +/// Represents raw homeserver tag with id +/// URI: /pub/pubky.app/tags/:URI_TAGGED_OBJECT/:label +/// +/// Example URI: +/// +/// `/pub/pubky.app/tags/pxnu33x7jtpx9ar1ytsi4yxbp6a5o36gwhffs8zoxmbuptici1jy/pub/pubky.app/posts/2ZKGWXZ44J300/cool` +/// +#[derive(Serialize, Deserialize, Default)] +pub struct HomeserverTag { + pub created_at: i64, +} diff --git a/src/models/homeserver/user.rs b/src/models/homeserver/user.rs index 0c437a4a..0dc8e51e 100644 --- a/src/models/homeserver/user.rs +++ b/src/models/homeserver/user.rs @@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize}; use utoipa::ToSchema; /// Profile schema +/// URI: /pub/pubky.app/profile.json #[derive(Deserialize, Serialize, Debug)] pub struct HomeserverUser { pub name: String, diff --git a/src/models/post/details.rs b/src/models/post/details.rs index 68127f11..55409c6c 100644 --- a/src/models/post/details.rs +++ b/src/models/post/details.rs @@ -1,24 +1,11 @@ +use super::PostStream; use crate::db::connectors::neo4j::get_neo4j_graph; +use crate::models::homeserver::PostKind; use crate::{queries, RedisOps}; use neo4rs::Node; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; -use super::PostStream; - -/// Represents the type of pubky-app posted data -/// Used primarily to best display the content in UI -#[derive(Serialize, Deserialize, ToSchema, Default)] -pub enum PostKind { - #[default] - Short, - Long, - Image, - Video, - Link, - File, -} - /// Represents post data with content, bio, image, links, and status. #[derive(Serialize, Deserialize, ToSchema, Default)] pub struct PostDetails { diff --git a/src/models/post/mod.rs b/src/models/post/mod.rs index 0fe81be8..b438fd79 100644 --- a/src/models/post/mod.rs +++ b/src/models/post/mod.rs @@ -8,7 +8,7 @@ mod view; pub use bookmark::Bookmark; pub use counts::PostCounts; -pub use details::{PostDetails, PostKind}; +pub use details::PostDetails; pub use relationships::PostRelationships; pub use stream::{PostStream, PostStreamReach, PostStreamSorting}; pub use thread::PostThread; diff --git a/src/routes/v0/post/details.rs b/src/routes/v0/post/details.rs index 90a05f2f..02a784ca 100644 --- a/src/routes/v0/post/details.rs +++ b/src/routes/v0/post/details.rs @@ -1,4 +1,5 @@ -use crate::models::post::{PostDetails, PostKind}; +use crate::models::homeserver::PostKind; +use crate::models::post::PostDetails; use crate::routes::v0::endpoints::POST_DETAILS_ROUTE; use crate::{Error, Result}; use axum::extract::Path;