diff options
Diffstat (limited to 'adenosine/src/app_bsky/mod.rs')
-rw-r--r-- | adenosine/src/app_bsky/mod.rs | 169 |
1 files changed, 119 insertions, 50 deletions
diff --git a/adenosine/src/app_bsky/mod.rs b/adenosine/src/app_bsky/mod.rs index 76352f5..61063fb 100644 --- a/adenosine/src/app_bsky/mod.rs +++ b/adenosine/src/app_bsky/mod.rs @@ -26,7 +26,6 @@ pub struct RefRecord { #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] pub struct FollowSubject { pub did: String, - // pub declarationCid: String, } #[allow(non_snake_case)] @@ -39,128 +38,158 @@ pub struct FollowRecord { #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] pub struct ProfileRecord { - pub displayName: String, + pub displayName: Option<String>, pub description: Option<String>, + pub avatar: Option<Blob>, + pub banner: Option<Blob>, + // TODO: self-labels } -// app.bsky.system.actorUser or app.bsky.system.actorScene -#[allow(non_snake_case)] -#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] -pub struct Declaration { - pub actorType: String, -} - -// actorType: app.bsky.system.actorUser -// cid: bafyreid27zk7lbis4zw5fz4podbvbs4fc5ivwji3dmrwa6zggnj4bnd57u #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] -pub struct DeclRef { - pub actorType: String, - pub cid: String, +pub struct Label { + pub src: String, + pub uri: String, + pub cid: Option<String>, + pub val: String, + pub neg: Option<bool>, + pub cts: String, } #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] pub struct ProfileView { pub did: String, - pub declaration: DeclRef, pub handle: String, - // for simple accounts, 'creator' is just the did - pub creator: String, pub displayName: Option<String>, pub description: Option<String>, - pub followersCount: u64, - pub followsCount: u64, - pub membersCount: u64, - pub postsCount: u64, - pub viewer: serde_json::Value, + pub avatar: Option<String>, + pub indexedAt: Option<String>, + pub viewer: Option<ViewerState>, + pub labels: Option<Vec<Label>>, } -/// for Timeline or AuthorFeed #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] -pub struct GenericFeed { - pub feed: Vec<FeedPostView>, +pub struct ViewerState { + pub muted: Option<bool>, + pub mutedByList: Option<Value>, // TODO + pub blockedBy: Option<bool>, + pub blocking: Option<String>, + pub following: Option<String>, + pub followedBy: Option<String>, } #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] -pub struct User { +pub struct ProfileViewBasic { pub did: String, pub handle: String, pub displayName: Option<String>, + pub avatar: Option<String>, + pub viewer: Option<Value>, + pub labels: Option<Vec<Label>>, } #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] -pub struct UserView { +pub struct ProfileViewDetailed { pub did: String, pub handle: String, - pub declaration: DeclRef, pub displayName: Option<String>, + pub description: Option<String>, pub avatar: Option<String>, - pub viewer: Option<Value>, + pub banner: Option<String>, + pub followersCount: u64, + pub followsCount: u64, + pub postsCount: u64, + pub indexedAt: Option<String>, + pub viewer: Option<ViewerState>, + pub labels: Option<Vec<Label>>, } +/// for Timeline or AuthorFeed +#[allow(non_snake_case)] +#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] +pub struct GenericFeed { + pub cursor: Option<String>, + pub feed: Vec<FeedViewPost>, +} +/* XXX: +#[allow(non_snake_case)] +#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] +pub struct User { + pub did: String, + pub handle: String, + pub displayName: Option<String>, +} +*/ + #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] pub struct PostView { pub uri: String, pub cid: String, - pub author: UserView, - pub record: Post, + pub author: ProfileViewBasic, + pub record: PostRecord, pub embed: Option<PostEmbedView>, pub replyCount: u64, pub repostCount: u64, - pub upvoteCount: u64, - pub downvoteCount: u64, + pub likeCount: u64, pub indexedAt: String, pub viewer: Option<Value>, + pub labels: Option<Vec<Label>>, } #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] -pub struct ThreadPostView { +pub struct ThreadViewPost { // TODO: doing this as the intersetion of #threadViewPost and #notFoundPost. actually it is // supposed to be a union type // #notFoundPost fields (uri and notFound actually required) pub uri: Option<String>, pub notFound: Option<bool>, + // #blockedPost fields (uri and blocked actually required) + pub blocked: Option<bool>, + pub author: Option<Value>, // #threadViewPost fields (post actually required) pub post: Option<PostView>, - pub parent: Option<Box<ThreadPostView>>, - pub replies: Option<Vec<ThreadPostView>>, + pub parent: Option<Box<ThreadViewPost>>, + pub replies: Option<Vec<ThreadViewPost>>, } #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] -pub struct FeedPostView { +pub struct FeedViewPost { pub post: PostView, - pub reply: Option<PostReply>, + pub reply: Option<ReplyRef>, // TODO: this could extend to other "reasons" in the future - pub reason: Option<RepostReason>, + pub reason: Option<ReasonRepost>, } #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] -pub struct RepostReason { - pub by: UserView, +pub struct ReasonRepost { + pub by: ProfileViewBasic, pub indexedAt: String, } #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] -pub struct Post { +pub struct PostRecord { pub text: String, - pub reply: Option<PostReply>, pub entities: Option<Vec<PostEntity>>, + pub facets: Option<Vec<RichtextFacet>>, + pub reply: Option<ReplyRef>, pub embed: Option<PostEmbed>, + pub langs: Option<Vec<String>>, + pub labels: Option<Vec<String>>, pub createdAt: Option<String>, } #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] -pub struct PostReply { +pub struct ReplyRef { // TODO: these should be StrongRef pub parent: Subject, pub root: Subject, @@ -168,6 +197,28 @@ pub struct PostReply { #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] +pub struct RichtextFacet { + pub index: ByteSlice, + pub features: Vec<FacetFeature>, +} + +#[allow(non_snake_case)] +#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] +pub struct FacetFeature { + // TODO: this is a hack; actually separate mention and link types + pub did: Option<String>, + pub uri: Option<String>, +} + +#[allow(non_snake_case)] +#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] +pub struct ByteSlice { + pub byteStart: u64, + pub byteEnd: u64, +} + +#[allow(non_snake_case)] +#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] pub struct PostEntity { pub index: TextSlice, pub r#type: String, @@ -186,13 +237,17 @@ pub struct TextSlice { pub struct PostEmbed { pub external: Option<EmbedExternal>, pub images: Option<Vec<EmbedImage>>, + pub record: Option<StrongRef>, + pub recordWithMedia: Option<Value>, // TODO } #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] pub struct PostEmbedView { - pub external: Option<EmbedExternalView>, pub images: Option<Vec<EmbedImageView>>, + pub external: Option<EmbedExternalView>, + pub record: Option<Value>, // TODO + pub recordWithMedia: Option<Value>, // TODO } #[allow(non_snake_case)] @@ -223,8 +278,20 @@ pub struct EmbedImage { #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] pub struct Blob { - pub cid: String, + #[serde(rename = "$type")] + pub blob_type: Option<String>, + #[serde(rename = "ref")] + pub link: Option<CidLink>, + pub cid: Option<String>, // deprecated pub mimeType: String, + pub size: Option<u64>, +} + +#[allow(non_snake_case)] +#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] +pub struct CidLink { + #[serde(rename = "$link")] + pub cid: String, } #[allow(non_snake_case)] @@ -238,9 +305,10 @@ pub struct EmbedImageView { #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] pub struct PostThread { - pub thread: ThreadPostView, + pub thread: ThreadViewPost, } +/* XXX #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] pub struct FollowTarget { @@ -252,11 +320,12 @@ pub struct FollowTarget { pub createdAt: Option<String>, pub indexedAt: String, } +*/ #[allow(non_snake_case)] #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)] -pub struct Follow { - // TODO: nested follow list? +pub struct FollowList { pub subject: Subject, - pub follows: FollowTarget, + pub cursor: Option<String>, + pub follows: Vec<ProfileView>, } |