summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md11
-rw-r--r--TODO3
-rw-r--r--adenosine-pds/src/db_bsky.rs48
-rw-r--r--adenosine-pds/src/lib.rs8
-rw-r--r--adenosine/src/repo.rs26
5 files changed, 33 insertions, 63 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index df9acdc..17548c4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,13 +6,16 @@
Refactored common library code into `adenosine` crate. Will put common types,
helpers, and probably client code and generated Lexicon code there.
-## Changed
+## Added
+
+- mst: interop tests with upstream `atproto` (Typescript) repository
+
+## Fixed
- mst: include "empty" intermediate nodes between layers (following upstream
behavior)
-
-## Added
-- mst: interop tests with upstream `atproto` (Typescript) repository
+- repo: MST keys should not have leading `/` before collection NSID (following
+ upstream behavior)
## [0.2.0] - 2022-12-19
diff --git a/TODO b/TODO
index 7f00de2..139e768 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,4 @@
-PDS:
-- keys in MST (repo) should NOT have leading slash (!)
-
CLI:
- register and login commands should do more than just dump JSON
=> return shell 'export' command (for easier config)
diff --git a/adenosine-pds/src/db_bsky.rs b/adenosine-pds/src/db_bsky.rs
index dfe8299..834053e 100644
--- a/adenosine-pds/src/db_bsky.rs
+++ b/adenosine-pds/src/db_bsky.rs
@@ -68,7 +68,7 @@ pub fn bsky_get_profile(srv: &mut AtpService, did: &Did) -> Result<app_bsky::Pro
};
let last_commit = srv.repo.get_commit(&commit_cid)?;
let full_map = srv.repo.mst_to_map(&last_commit.mst_cid)?;
- let prefix = "/app.bsky.actor.profile/";
+ let prefix = "app.bsky.actor.profile/";
for (mst_key, cid) in full_map.iter() {
if mst_key.starts_with(prefix) {
profile_cid = Some(*cid);
@@ -134,10 +134,10 @@ pub fn bsky_update_profile(
};
let last_commit = srv.repo.get_commit(&commit_cid)?;
let full_map = srv.repo.mst_to_map(&last_commit.mst_cid)?;
- let prefix = "/app.bsky.actor.profile/";
+ let prefix = "app.bsky.actor.profile/";
for (mst_key, _cid) in full_map.iter() {
if mst_key.starts_with(prefix) {
- profile_tid = Some(Tid::from_str(mst_key.split('/').nth(2).unwrap())?);
+ profile_tid = Some(Tid::from_str(mst_key.split('/').nth(1).unwrap())?);
}
}
let profile_tid: Tid = profile_tid.unwrap_or(srv.tid_gen.next_tid());
@@ -532,12 +532,7 @@ fn test_bsky_feeds() {
bsky_mutate_db(&mut srv.atp_db, &alice_did, mutations).unwrap();
// bob follows alice, likes first post, reposts second, replies third
- let alice_post3_uri = format!(
- "at://{}/{}/{}",
- alice_did,
- post_nsid,
- alice_post3_tid
- );
+ let alice_post3_uri = format!("at://{}/{}/{}", alice_did, post_nsid, alice_post3_tid);
let mutations = vec![
Mutation::Create(
follow_nsid.clone(),
@@ -593,12 +588,7 @@ fn test_bsky_feeds() {
assert_eq!(
alice_feed.feed[2].uri,
- format!(
- "at://{}/{}/{}",
- alice_did,
- post_nsid,
- alice_post1_tid
- )
+ format!("at://{}/{}/{}", alice_did, post_nsid, alice_post1_tid)
);
// TODO: CID
assert_eq!(alice_feed.feed[2].author.did, alice_did.to_string());
@@ -633,12 +623,7 @@ fn test_bsky_feeds() {
assert_eq!(bob_timeline.feed.len(), 3);
assert_eq!(
bob_timeline.feed[2].uri,
- format!(
- "at://{}/{}/{}",
- alice_did,
- post_nsid,
- alice_post1_tid
- )
+ format!("at://{}/{}/{}", alice_did, post_nsid, alice_post1_tid)
);
// TODO: CID
assert_eq!(bob_timeline.feed[2].author.did, alice_did.to_string());
@@ -716,12 +701,7 @@ fn test_bsky_thread() {
.mutate_repo(&alice_did, &mutations, &srv.pds_keypair)
.unwrap();
bsky_mutate_db(&mut srv.atp_db, &alice_did, mutations).unwrap();
- let alice_post1_uri = format!(
- "at://{}/{}/{}",
- alice_did,
- post_nsid,
- alice_post1_tid
- );
+ let alice_post1_uri = format!("at://{}/{}/{}", alice_did, post_nsid, alice_post1_tid);
// bob likes and replies first post
let bob_post1_tid = srv.tid_gen.next_tid();
@@ -734,12 +714,7 @@ fn test_bsky_thread() {
.mutate_repo(&bob_did, &mutations, &srv.pds_keypair)
.unwrap();
bsky_mutate_db(&mut srv.atp_db, &bob_did, mutations).unwrap();
- let bob_post1_uri = format!(
- "at://{}/{}/{}",
- bob_did,
- post_nsid,
- bob_post1_tid
- );
+ let bob_post1_uri = format!("at://{}/{}/{}", bob_did, post_nsid, bob_post1_tid);
// alice replies to bob reply
let alice_post2_tid = srv.tid_gen.next_tid();
@@ -752,12 +727,7 @@ fn test_bsky_thread() {
.mutate_repo(&alice_did, &mutations, &srv.pds_keypair)
.unwrap();
bsky_mutate_db(&mut srv.atp_db, &alice_did, mutations).unwrap();
- let _alice_post2_uri = format!(
- "at://{}/{}/{}",
- alice_did,
- post_nsid,
- alice_post2_tid
- );
+ let _alice_post2_uri = format!("at://{}/{}/{}", alice_did, post_nsid, alice_post2_tid);
// get thread from bob's post
// TODO: should have both parent and children
diff --git a/adenosine-pds/src/lib.rs b/adenosine-pds/src/lib.rs
index fb63a11..5a2266e 100644
--- a/adenosine-pds/src/lib.rs
+++ b/adenosine-pds/src/lib.rs
@@ -307,7 +307,7 @@ fn xrpc_get_handler(
let collection = Nsid::from_str(&xrpc_required_param(request, "collection")?)?;
let rkey = Tid::from_str(&xrpc_required_param(request, "rkey")?)?;
let mut srv = srv.lock().or(Err(XrpcError::MutexPoisoned))?;
- let key = format!("/{collection}/{rkey}");
+ let key = format!("{collection}/{rkey}");
match srv.repo.get_atp_record(&did, &collection, &rkey) {
// TODO: format as JSON, not text debug
Ok(Some(ipld)) => Ok(ipld_into_json_value(ipld)),
@@ -336,7 +336,7 @@ fn xrpc_get_handler(
let commit_cid = &srv.repo.lookup_commit(&did)?.unwrap();
let last_commit = srv.repo.get_commit(commit_cid)?;
let full_map = srv.repo.mst_to_map(&last_commit.mst_cid)?;
- let prefix = format!("/{collection}/");
+ let prefix = format!("{collection}/");
for (mst_key, cid) in full_map.iter() {
//debug!("{}", mst_key);
if mst_key.starts_with(&prefix) {
@@ -844,7 +844,7 @@ fn collection_view_handler(
let commit_cid = &srv.repo.lookup_commit(&did)?.unwrap();
let last_commit = srv.repo.get_commit(commit_cid)?;
let full_map = srv.repo.mst_to_map(&last_commit.mst_cid)?;
- let prefix = format!("/{collection}/");
+ let prefix = format!("{collection}/");
for (mst_key, cid) in full_map.iter() {
debug!("{}", mst_key);
if mst_key.starts_with(&prefix) {
@@ -880,7 +880,7 @@ fn record_view_handler(
let rkey = Tid::from_str(tid)?;
let mut srv = srv.lock().or(Err(XrpcError::MutexPoisoned))?;
- let key = format!("/{collection}/{rkey}");
+ let key = format!("{collection}/{rkey}");
let record = match srv.repo.get_atp_record(&did, &collection, &rkey) {
Ok(Some(ipld)) => ipld_into_json_value(ipld),
Ok(None) => Err(anyhow!(XrpcError::NotFound(format!(
diff --git a/adenosine/src/repo.rs b/adenosine/src/repo.rs
index 280fe6d..b05a933 100644
--- a/adenosine/src/repo.rs
+++ b/adenosine/src/repo.rs
@@ -196,7 +196,7 @@ impl RepoStore {
} else {
return Ok(None);
};
- let record_key = format!("/{collection}/{tid}");
+ let record_key = format!("{collection}/{tid}");
self.get_mst_record_by_key(&commit.mst_cid, &record_key)
}
@@ -244,14 +244,14 @@ impl RepoStore {
match m {
Mutation::Create(collection, tid, val) => {
let cid = self.put_ipld(val)?;
- cid_map.insert(format!("/{collection}/{tid}"), cid);
+ cid_map.insert(format!("{collection}/{tid}"), cid);
}
Mutation::Update(collection, tid, val) => {
let cid = self.put_ipld(val)?;
- cid_map.insert(format!("/{collection}/{tid}"), cid);
+ cid_map.insert(format!("{collection}/{tid}"), cid);
}
Mutation::Delete(collection, tid) => {
- cid_map.remove(&format!("/{collection}/{tid}"));
+ cid_map.remove(&format!("{collection}/{tid}"));
}
}
}
@@ -374,14 +374,14 @@ fn test_repo_mst() {
let empty_map_cid = repo.mst_from_map(&map).unwrap();
assert_eq!(map, repo.mst_to_map(&empty_map_cid).unwrap());
assert!(repo
- .get_mst_record_by_key(&empty_map_cid, "/test.records/44444444444444")
+ .get_mst_record_by_key(&empty_map_cid, "test.records/44444444444444")
.unwrap()
.is_none());
- map.insert("/blobs/1".to_string(), blob_cid);
- map.insert("/blobs/2".to_string(), blob_cid);
- map.insert("/test.records/44444444444444".to_string(), record_cid);
- map.insert("/test.records/22222222222222".to_string(), record_cid);
+ map.insert("blobs/1".to_string(), blob_cid);
+ map.insert("blobs/2".to_string(), blob_cid);
+ map.insert("test.records/44444444444444".to_string(), record_cid);
+ map.insert("test.records/22222222222222".to_string(), record_cid);
let simple_map_cid = repo.mst_from_map(&map).unwrap();
assert_eq!(map, repo.mst_to_map(&simple_map_cid).unwrap());
@@ -393,7 +393,7 @@ fn test_repo_mst() {
.unwrap();
assert_eq!(
Some(record.clone()),
- repo.get_mst_record_by_key(&simple_map_cid, "/test.records/44444444444444")
+ repo.get_mst_record_by_key(&simple_map_cid, "test.records/44444444444444")
.unwrap()
);
assert_eq!(
@@ -406,7 +406,7 @@ fn test_repo_mst() {
.unwrap()
);
assert!(repo
- .get_mst_record_by_key(&simple_map_cid, "/test.records/33333333333333")
+ .get_mst_record_by_key(&simple_map_cid, "test.records/33333333333333")
.unwrap()
.is_none());
assert!(repo
@@ -419,7 +419,7 @@ fn test_repo_mst() {
.is_none());
assert_eq!(Some(simple_commit_cid), repo.lookup_commit(&did).unwrap());
- map.insert("/test.records/33333333333333".to_string(), record_cid);
+ map.insert("test.records/33333333333333".to_string(), record_cid);
let simple3_map_cid = repo.mst_from_map(&map).unwrap();
let simple3_root_cid = repo
.write_root(meta_cid, Some(simple_commit_cid), simple3_map_cid)
@@ -430,7 +430,7 @@ fn test_repo_mst() {
assert_eq!(map, repo.mst_to_map(&simple3_map_cid).unwrap());
assert_eq!(
Some(record.clone()),
- repo.get_mst_record_by_key(&simple3_map_cid, "/test.records/33333333333333")
+ repo.get_mst_record_by_key(&simple3_map_cid, "test.records/33333333333333")
.unwrap()
);
assert_eq!(