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.

Add get profile endpoint #9

open opened by willdot.net targeting main from push-szttzpqmmmso
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:dadhhalkfcq3gucaq25hjqon/sh.tangled.repo.pull/3mkxgx22c6s22
+159 -9
Diff #0
+130 -7
src/server.rs
··· 13 13 use std::net::SocketAddr; 14 14 15 15 use jacquard_api::{ 16 - app_bsky::feed::{get_feed::GetFeedRequest, get_timeline::GetTimelineRequest}, 16 + app_bsky::{ 17 + actor::get_profile::{GetProfile, GetProfileRequest}, 18 + feed::{get_feed::GetFeedRequest, get_timeline::GetTimelineRequest}, 19 + }, 17 20 com_atproto::repo::get_record::GetRecordRequest, 18 21 }; 19 22 20 23 use crate::xrpc::routes::{ 21 - app_bsky_feed_get_feed, app_bsky_feed_get_timeline, com_atproto_repo_get_record, 24 + app_bsky_actor_get_profile, app_bsky_feed_get_feed, app_bsky_feed_get_timeline, 25 + com_atproto_repo_get_record, 22 26 }; 23 27 24 28 #[derive(Clone)] ··· 42 46 43 47 44 48 49 + let service_did = Did::new_owned(appview_did).expect("APPVIEW_DID produced an invalid did:web"); 45 50 51 + let resolver = JacquardResolver::new(reqwest::Client::new(), ResolverOptions::default()); 52 + let auth_config = ServiceAuthConfig::new(service_did, resolver.clone()); 46 53 54 + let app_state = AppState::new(server_config, auth_config, resolver.clone()); 47 55 56 + let app = Router::<AppState>::new() 57 + .route("/", get(say_hello_text)) 48 58 49 59 50 60 ··· 52 62 53 63 54 64 65 + .merge(GetRecordRequest::into_router::<_, AppState, _>( 66 + com_atproto_repo_get_record, 67 + )) 68 + .merge(GetProfileRequest::into_router::<_, AppState, _>( 69 + app_bsky_actor_get_profile, 70 + )) 71 + .with_state(app_state); 55 72 73 + let addr: SocketAddr = format!("{host}:{port}") 56 74 57 75 58 76 59 77 60 78 61 - .merge(GetRecordRequest::into_router::<_, AppState, _>( 62 - com_atproto_repo_get_record, 63 - )) 64 - .with_state(app_state); 65 79 66 - let addr: SocketAddr = format!("{host}:{port}") 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 + 100 + 101 + 102 + 103 + 104 + 105 + 106 + 107 + 108 + 109 + 110 + 111 + 112 + 113 + 114 + 115 + 116 + 117 + 118 + 119 + 120 + 121 + 122 + 123 + 124 + 125 + 126 + 127 + 128 + 129 + 130 + 131 + 132 + 133 + 134 + 135 + 136 + 137 + 138 + 139 + 140 + 141 + 142 + 143 + 144 + 145 + 146 + 147 + 148 + 149 + 150 + 151 + 152 + 153 + 154 + 155 + 156 + 157 + 158 + 159 + 160 + 161 + 162 + 163 + 164 + 165 + 166 + 167 + 168 + 169 + 170 + 171 + pub struct AppState { 172 + server_config: ServerConfig, 173 + pub service_auth: ServiceAuthConfig<JacquardResolver>, 174 + pub resolver: JacquardResolver, 175 + } 176 + 177 + impl AppState { 178 + pub fn new( 179 + server_config: ServerConfig, 180 + service_auth: ServiceAuthConfig<JacquardResolver>, 181 + resolver: JacquardResolver, 182 + ) -> Self { 183 + Self { 184 + service_auth: service_auth, 185 + server_config: server_config, 186 + resolver: resolver, 187 + } 188 + } 189 + }
+29 -2
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; 6 + use jacquard_api::app_bsky::actor::get_profile::GetProfileOutput; 7 + use jacquard_api::app_bsky::actor::get_profile::GetProfileRequest; 5 8 use jacquard_api::app_bsky::feed::get_timeline::GetTimelineOutput; 6 9 use jacquard_api::app_bsky::feed::{ 7 10 get_feed::{GetFeedOutput, GetFeedRequest}, 8 11 get_timeline::GetTimelineRequest, 9 12 }; 10 - 11 13 use jacquard_api::tools_ozone::moderation::get_record::GetRecordRequest; 12 14 use jacquard_axum::ExtractXrpc; 13 15 use jacquard_axum::service_auth::ExtractOptionalServiceAuth; 16 + use jacquard_common::IntoStatic; 17 + use jacquard_identity::resolver::IdentityResolver; 14 18 use serde_json::Value; 15 19 use serde_json::json; 16 20 21 + pub async fn app_bsky_actor_get_profile( 22 + State(state): State<AppState>, 23 + ExtractOptionalServiceAuth(_auth): ExtractOptionalServiceAuth, 24 + ExtractXrpc(req): ExtractXrpc<GetProfileRequest>, 25 + ) -> Result<Json<GetProfileOutput<'static>>, XrpcErrorResponse> { 26 + let did = match req.actor { 27 + AtIdentifier::Did(did) => did.into_static(), 28 + AtIdentifier::Handle(handle) => { 29 + state 30 + .resolver 31 + .resolve_handle(&handle) 32 + .await 33 + .map_err(|err| { 34 + println!("error resolving handle: {err}"); 35 + XrpcErrorResponse::internal_server_error() 36 + })? 37 + } 38 + }; 39 + 40 + println!("did is {did}"); 41 + return Err(XrpcErrorResponse::not_implemented()); 42 + } 43 + 17 44 pub async fn com_atproto_repo_get_record( 18 45 State(_): State<AppState>, 19 46 ExtractOptionalServiceAuth(_auth): ExtractOptionalServiceAuth,

History

1 round 0 comments
sign up or login to add to the discussion
willdot.net submitted #0
2 commits
expand
add get profile endpoint but return unimplemented
print out the did from the request by resolving it
merge conflicts detected
expand
  • src/server.rs:13
  • src/xrpc/routes.rs:2
expand 0 comments