A personal app view to see Bsky posts of your followers (for when their app view goes down)
17
fork

Configure Feed

Select the types of activity you want to include in your feed.

print out the did provided in the request #5

open opened by willdot.net targeting main from push-uqytxwxtzsuo

Signed-off-by: Will did:plc:dadhhalkfcq3gucaq25hjqon

use the resolver to resolve the request actor

Signed-off-by: Will did:plc:dadhhalkfcq3gucaq25hjqon

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:dadhhalkfcq3gucaq25hjqon/sh.tangled.repo.pull/3mkxfpr2mtx22
+26 -5
Diff #0
+5 -2
src/server.rs
··· 49 49 let service_did = Did::new_owned(appview_did).expect("APPVIEW_DID produced an invalid did:web"); 50 50 51 51 let resolver = JacquardResolver::new(reqwest::Client::new(), ResolverOptions::default()); 52 - let auth_config = ServiceAuthConfig::new(service_did, resolver); 52 + let auth_config = ServiceAuthConfig::new(service_did, resolver.clone()); 53 53 54 - let app_state = AppState::new(server_config, auth_config); 54 + let app_state = AppState::new(server_config, auth_config, resolver.clone()); 55 55 56 56 let app = Router::<AppState>::new() 57 57 .route("/", get(say_hello_text)) ··· 170 170 #[derive(Clone)] 171 171 pub struct AppState { 172 172 server_config: ServerConfig, 173 + pub resolver: JacquardResolver, 173 174 pub service_auth: ServiceAuthConfig<JacquardResolver>, 174 175 } 175 176 ··· 177 178 pub fn new( 178 179 server_config: ServerConfig, 179 180 service_auth: ServiceAuthConfig<JacquardResolver>, 181 + resolver: JacquardResolver, 180 182 ) -> Self { 181 183 Self { 182 184 service_auth: service_auth, 185 + resolver: resolver, 183 186 server_config: server_config, 184 187 } 185 188 }
+21 -3
src/xrpc/routes.rs
··· 1 1 use crate::server::AppState; 2 2 use crate::server::XrpcErrorResponse; 3 3 use axum::{Json, extract::State}; 4 + use jacquard::types::string::AtIdentifier; 4 5 use jacquard::xrpc::atproto::GetRecordOutput; 5 6 use jacquard_api::app_bsky::actor::get_profile::GetProfileOutput; 6 7 use jacquard_api::app_bsky::actor::get_profile::GetProfileRequest; ··· 9 10 get_feed::{GetFeedOutput, GetFeedRequest}, 10 11 get_timeline::GetTimelineRequest, 11 12 }; 12 - 13 13 use jacquard_api::tools_ozone::moderation::get_record::GetRecordRequest; 14 14 use jacquard_axum::ExtractXrpc; 15 15 use jacquard_axum::service_auth::ExtractOptionalServiceAuth; 16 + use jacquard_common::IntoStatic; 17 + use jacquard_identity::resolver::IdentityResolver; 16 18 use serde_json::Value; 17 19 use serde_json::json; 18 20 ··· 25 27 } 26 28 27 29 pub async fn app_bsky_actor_get_profile( 28 - State(_): State<AppState>, 30 + State(state): State<AppState>, 29 31 ExtractOptionalServiceAuth(_auth): ExtractOptionalServiceAuth, 30 - ExtractXrpc(_): ExtractXrpc<GetProfileRequest>, 32 + ExtractXrpc(req): ExtractXrpc<GetProfileRequest>, 31 33 ) -> Result<Json<GetProfileOutput<'static>>, XrpcErrorResponse> { 34 + let did = match req.actor { 35 + AtIdentifier::Did(did) => did.into_static(), 36 + AtIdentifier::Handle(handle) => { 37 + state 38 + .resolver 39 + .resolve_handle(&handle) 40 + .await 41 + .map_err(|err| { 42 + println!("error resolving handle: {err}"); 43 + XrpcErrorResponse::internal_server_error() 44 + })? 45 + } 46 + }; 47 + 48 + println!("did is {did}"); 49 + 32 50 return Err(XrpcErrorResponse::not_implemented()); 33 51 } 34 52

History

1 round 0 comments
sign up or login to add to the discussion
willdot.net submitted #0
1 commit
expand
print out the did provided in the request
merge conflicts detected
expand
  • src/server.rs:13
  • src/xrpc/routes.rs:2
expand 0 comments