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.

added get profile and return not implemented #3

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

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/3mkxfpcw6yl22
+163 -13
Diff #0
+129 -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 + #[derive(Clone)] 171 + pub struct AppState { 172 + server_config: ServerConfig, 173 + pub resolver: JacquardResolver, 174 + pub service_auth: ServiceAuthConfig<JacquardResolver>, 175 + } 176 + 177 + 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 + resolver: resolver, 186 + server_config: server_config, 187 + } 188 + }
+34 -6
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}, 11 + get_timeline::GetTimelineRequest, 12 + }; 13 + use jacquard_api::tools_ozone::moderation::get_record::GetRecordRequest; 14 + use jacquard_axum::ExtractXrpc; 15 + use jacquard_axum::service_auth::ExtractOptionalServiceAuth; 16 + use jacquard_common::IntoStatic; 17 + use jacquard_identity::resolver::IdentityResolver; 18 + use serde_json::Value; 19 + use serde_json::json; 8 20 9 21 10 22 11 23 12 24 13 25 26 + return Err(XrpcErrorResponse::not_implemented()); 27 + } 14 28 29 + pub async fn app_bsky_actor_get_profile( 30 + State(state): State<AppState>, 31 + ExtractOptionalServiceAuth(_auth): ExtractOptionalServiceAuth, 32 + ExtractXrpc(req): ExtractXrpc<GetProfileRequest>, 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 + }; 15 47 16 - 17 - 18 - 19 - 20 - 48 + println!("did is {did}"); 21 49 22 50 return Err(XrpcErrorResponse::not_implemented()); 23 51 }

History

1 round 0 comments
sign up or login to add to the discussion
willdot.net submitted #0
3 commits
expand
added get profile and return not implemented
print out the did provided in the request
use the resolver to resolve the request actor
merge conflicts detected
expand
  • src/server.rs:13
  • src/xrpc/routes.rs:2
expand 0 comments