aboutsummaryrefslogtreecommitdiffstats
path: root/adenosine
diff options
context:
space:
mode:
authorbryan newbold <bnewbold@robocracy.org>2023-08-20 19:56:22 -0700
committerbryan newbold <bnewbold@robocracy.org>2023-08-20 19:56:22 -0700
commit23416af782a179a658711e958e977e19ae97067b (patch)
tree09e605dbd105c0628f6614e421c0dd43bb8ce3dc /adenosine
parentcc1dea6ea34260201c1df09959c7c4566d16d918 (diff)
downloadadenosine-23416af782a179a658711e958e977e19ae97067b.tar.gz
adenosine-23416af782a179a658711e958e977e19ae97067b.zip
many updates from spring 2023 lex refactor
Diffstat (limited to 'adenosine')
-rw-r--r--adenosine/src/app_bsky/mod.rs169
-rw-r--r--adenosine/src/com_atproto/mod.rs6
-rw-r--r--adenosine/src/com_atproto/repo/mod.rs20
-rw-r--r--adenosine/src/xrpc.rs6
4 files changed, 143 insertions, 58 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>,
}
diff --git a/adenosine/src/com_atproto/mod.rs b/adenosine/src/com_atproto/mod.rs
index 8e2317a..7a6cbc0 100644
--- a/adenosine/src/com_atproto/mod.rs
+++ b/adenosine/src/com_atproto/mod.rs
@@ -7,15 +7,16 @@ pub mod repo;
pub struct AccountRequest {
pub email: String,
pub handle: String,
- pub password: String,
+ pub did: Option<String>,
pub inviteCode: Option<String>,
+ pub password: String,
pub recoveryKey: Option<String>,
}
#[allow(non_snake_case)]
#[derive(Debug, serde::Deserialize, serde::Serialize, PartialEq, Eq)]
pub struct SessionRequest {
- pub handle: String,
+ pub identifier: String,
pub password: String,
}
@@ -24,6 +25,7 @@ pub struct SessionRequest {
pub struct Session {
pub did: String,
pub name: String,
+ pub email: Option<String>,
pub accessJwt: String,
pub refreshJwt: String,
}
diff --git a/adenosine/src/com_atproto/repo/mod.rs b/adenosine/src/com_atproto/repo/mod.rs
index aa66e98..de5b56b 100644
--- a/adenosine/src/com_atproto/repo/mod.rs
+++ b/adenosine/src/com_atproto/repo/mod.rs
@@ -3,11 +3,11 @@
#[allow(non_snake_case)]
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)]
pub struct Describe {
- pub name: String,
+ pub handle: String,
pub did: String,
pub didDoc: serde_json::Value,
pub collections: Vec<String>,
- pub nameIsCorrect: bool,
+ pub handleIsCorrect: bool,
}
#[allow(non_snake_case)]
@@ -15,7 +15,10 @@ pub struct Describe {
pub struct CreateRecord {
pub did: String,
pub collection: String,
+ pub rkey: Option<String>,
+ pub validate: Option<bool>,
pub record: serde_json::Value,
+ pub swapCommit: Option<String>,
}
#[allow(non_snake_case)]
@@ -24,7 +27,10 @@ pub struct PutRecord {
pub did: String,
pub collection: String,
pub rkey: String,
+ pub validate: Option<bool>,
pub record: serde_json::Value,
+ pub swapRecord: Option<String>,
+ pub swapCommit: Option<String>,
}
#[allow(non_snake_case)]
@@ -33,21 +39,25 @@ pub struct DeleteRecord {
pub did: String,
pub collection: String,
pub rkey: String,
+ pub swapRecord: Option<String>,
+ pub swapCommit: Option<String>,
}
#[allow(non_snake_case)]
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)]
pub struct BatchWriteBody {
- pub did: String,
+ pub repo: String,
+ pub validate: Option<bool>,
pub writes: Vec<BatchWrite>,
+ pub swapCommit: Option<String>,
}
#[allow(non_snake_case)]
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq)]
pub struct BatchWrite {
- #[serde(rename = "type")]
+ #[serde(rename = "$type")]
pub op_type: String,
pub collection: String,
pub rkey: Option<String>,
- pub value: serde_json::Value,
+ pub value: Option<serde_json::Value>,
}
diff --git a/adenosine/src/xrpc.rs b/adenosine/src/xrpc.rs
index 6a89ba1..2a185ce 100644
--- a/adenosine/src/xrpc.rs
+++ b/adenosine/src/xrpc.rs
@@ -106,7 +106,11 @@ impl XrpcClient {
/// Uses refresh token to update auth token
pub fn auth_refresh(&mut self) -> Result<()> {
self.auth_token = self.refresh_token.clone();
- let resp = self.post(&Nsid::from_str("com.atproto.session.refresh")?, None, None)?;
+ let resp = self.post(
+ &Nsid::from_str("com.atproto.server.refreshSession")?,
+ None,
+ None,
+ )?;
let resp = resp.ok_or(anyhow!("missing session auth info"))?;
self.auth_token = resp["accessJwt"].as_str().map(|s| s.to_string());
self.refresh_token = resp["refreshJwt"].as_str().map(|s| s.to_string());