summaryrefslogtreecommitdiffstats
path: root/adenosine-pds/src/lib.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2022-11-09 15:47:22 -0800
committerBryan Newbold <bnewbold@robocracy.org>2022-11-09 15:47:22 -0800
commit9ca31fd3713ed9bcf1e1eb601c022afcb4fc4d74 (patch)
tree3b2e4a2e23789871a53c4109c1fac7d1bd77cf15 /adenosine-pds/src/lib.rs
parent7af51292ddfc81d55dd5beff07c557757bb0075f (diff)
downloadadenosine-9ca31fd3713ed9bcf1e1eb601c022afcb4fc4d74.tar.gz
adenosine-9ca31fd3713ed9bcf1e1eb601c022afcb4fc4d74.zip
pds: session.get and handle.resolve XRPC endpoints
Diffstat (limited to 'adenosine-pds/src/lib.rs')
-rw-r--r--adenosine-pds/src/lib.rs32
1 files changed, 18 insertions, 14 deletions
diff --git a/adenosine-pds/src/lib.rs b/adenosine-pds/src/lib.rs
index 738a061..7b517f2 100644
--- a/adenosine-pds/src/lib.rs
+++ b/adenosine-pds/src/lib.rs
@@ -383,21 +383,25 @@ fn xrpc_get_handler(
}
Ok(json!({ "records": record_list }))
}
- "com.atproto.repo.describe" => {
- let did = Did::from_str(&xrpc_required_param(request, "user")?)?;
- // TODO: resolve handle?
- let handle = did.to_string();
+ "com.atproto.session.get" => {
let mut srv = srv.lock().expect("service mutex");
- let did_doc = srv.atp_db.get_did_doc(&did)?;
- let collections: Vec<String> = srv.repo.collections(&did)?;
- let desc = RepoDescribe {
- name: handle,
- did: did.to_string(),
- didDoc: did_doc,
- collections: collections,
- nameIsCorrect: true,
- };
- Ok(json!(desc))
+ let auth_did = &xrpc_check_auth_header(&mut srv, request, None)?;
+ let handle = srv
+ .atp_db
+ .resolve_did(auth_did)?
+ .expect("registered account has handle");
+ Ok(json!({"did": auth_did.to_string(), "handle": handle}))
+ }
+ "com.atproto.handle.resolve" => {
+ let handle = xrpc_required_param(request, "handle")?;
+ let mut srv = srv.lock().expect("service mutex");
+ match srv.atp_db.resolve_handle(&handle)? {
+ Some(did) => Ok(json!({"did": did.to_string()})),
+ None => Err(XrpcError::NotFound(format!(
+ "could not resolve handle internally: {}",
+ handle
+ )))?,
+ }
}
// =========== app.bsky methods
"app.bsky.actor.getProfile" => {