Something went wrong. Try again.
A small api and web interface to lookup some general information about ATProto users
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364use axum::{Json, extract::Path};use serde_json::{json, Value};
use crate::{atproto::{did_resolver::{fetch_did_doc, identifier_to_did}, handle_resolver::extract_handle, pds_resolver::extract_pds}, errors::api_error::ApiError};
#[utoipa::path( get, path = "/user/{identifier}/identity", tag = "user", params( ("identifier" = String, Path, description = "Handle or DID") ), responses( ( status = 200, description = "Resolved identity", body = serde_json::Value, example = json!({ "did": "did:plc:ewvi7nxzyoun6zhxrhs64oiz", "handle": "example.com", "pds": "https://pds.example.com" }) ), ( status = 400, description = "Invalid handle or DID", body = serde_json::Value, example = json!({"error": "invalid handle or DID"}) ), ( status = 404, description = "No handle or PDS found for the DID", body = serde_json::Value, example = json!({"error": "No handles found associated with DID"}) ), ( status = 500, description = "Internal error: conversion, Redis, or unknown failure", body = serde_json::Value, example = json!({"error": "An unknown error occurred"}) ), ( status = 502, description = "Upstream resolution failed", body = serde_json::Value, example = json!({"error": "could not resolve identity"}) ) ))]pub async fn fetch_identity_data(Path(identifier): Path<String>) -> Result<Json<Value>, ApiError> { let did = identifier_to_did(identifier.clone()).await?; let doc = fetch_did_doc(did.clone()).await?;
let handle = extract_handle(doc.clone()).await?.to_string(); let pds = extract_pds(doc.clone()).await?; Ok(Json(json!({ "did": did.as_str(), "handle": handle, "pds": pds, })))}