ceres: a small planet in a giant solar system
33
fork

Configure Feed

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

get_pref endpoint

+26 -10
+26 -10
src/handlers/xrpc/app_bsky_actor.rs
··· 1 + use std::os::unix::prelude; 2 + 1 3 use crate::handlers::xrpc::XrpcErrorResponse; 2 4 use crate::state::AppState; 3 5 use axum::{ ··· 7 9 }; 8 10 use jacquard::{ 9 11 prelude::IdentityResolver, 10 - types::{datetime::Datetime, did::Did, handle::Handle, uri::UriValue}, 12 + types::{datetime::Datetime, did::Did, uri::UriValue}, 13 + xrpc::XrpcEndpoint, 11 14 }; 12 15 use jacquard_api::app_bsky::actor::{ 13 - ProfileViewDetailed, 16 + PreferencesItem, ProfileViewDetailed, 17 + get_preferences::{GetPreferencesOutput, GetPreferencesRequest}, 14 18 get_profile::{GetProfileOutput, GetProfileRequest}, 15 19 }; 16 20 use jacquard_axum::{ExtractXrpc, IntoRouter, service_auth::ExtractOptionalServiceAuth}; ··· 20 24 State(state): State<AppState>, 21 25 ExtractOptionalServiceAuth(auth): ExtractOptionalServiceAuth, 22 26 ExtractXrpc(req): ExtractXrpc<GetProfileRequest>, 23 - ) -> Result<Response, XrpcErrorResponse> { 27 + ) -> Result<Json<GetProfileOutput<'static>>, XrpcErrorResponse> { 24 28 info!("get_profile actor={}", req.actor.as_ref()); 25 29 let did = match req.actor { 26 30 jacquard::types::ident::AtIdentifier::Did(did) => did, ··· 44 48 XrpcErrorResponse::internal_server_error() 45 49 })?; 46 50 47 - let handle = did_doc.handles().get(0) 48 - .cloned() 49 - .ok_or_else(|| { 50 - log::error!("No handle found in DID document"); 51 - XrpcErrorResponse::internal_server_error() 52 - })?; 51 + let handle = did_doc.handles().get(0).cloned().ok_or_else(|| { 52 + log::error!("No handle found in DID document"); 53 + XrpcErrorResponse::internal_server_error() 54 + })?; 53 55 54 56 info!("{:?}", auth); 55 57 let profile = GetProfileOutput { ··· 96 98 extra_data: Default::default(), 97 99 }; 98 100 99 - Ok(Json(profile).into_response()) 101 + Ok(profile.into()) 102 + } 103 + 104 + pub async fn get_preferences() -> Result<Json<GetPreferencesOutput<'static>>, XrpcErrorResponse> { 105 + let preferences: Vec<PreferencesItem> = vec![]; 106 + 107 + let preference_output = GetPreferencesOutput { 108 + preferences, 109 + extra_data: Default::default(), 110 + }; 111 + 112 + Ok(preference_output.into()) 100 113 } 101 114 102 115 pub fn routes() -> Router<AppState> { 103 116 Router::<AppState>::new() 104 117 .merge(GetProfileRequest::into_router::<_, AppState, _>( 105 118 get_profile, 119 + )) 120 + .merge(GetPreferencesRequest::into_router::<_, AppState, _>( 121 + get_preferences, 106 122 )) 107 123 }