@@ -4,6 +4,7 @@ use axum_extra::json;
44use axum_extra:: response:: ErasedJson ;
55use diesel:: prelude:: * ;
66use diesel_async:: RunQueryDsl ;
7+ use futures_util:: FutureExt ;
78use http:: request:: Parts ;
89
910use crate :: app:: AppState ;
@@ -29,7 +30,8 @@ pub async fn get_authenticated_user(app: AppState, req: Parts) -> AppResult<Json
2930 . check ( & req, & mut conn)
3031 . await ?
3132 . user_id ( ) ;
32- let ( user, verified, email, verification_sent) : ( User , Option < bool > , Option < String > , bool ) =
33+
34+ let ( ( user, verified, email, verification_sent) , owned_crates) = tokio:: try_join!(
3335 users:: table
3436 . find( user_id)
3537 . left_join( emails:: table)
@@ -39,16 +41,18 @@ pub async fn get_authenticated_user(app: AppState, req: Parts) -> AppResult<Json
3941 emails:: email. nullable( ) ,
4042 emails:: token_generated_at. nullable( ) . is_not_null( ) ,
4143 ) )
42- . first ( & mut conn)
43- . await ?;
44+ . first:: <( User , Option <bool >, Option <String >, bool ) >( & mut conn)
45+ . boxed( ) ,
46+ CrateOwner :: by_owner_kind( OwnerKind :: User )
47+ . inner_join( crates:: table)
48+ . filter( crate_owners:: owner_id. eq( user_id) )
49+ . select( ( crates:: id, crates:: name, crate_owners:: email_notifications) )
50+ . order( crates:: name. asc( ) )
51+ . load( & mut conn)
52+ . boxed( )
53+ ) ?;
4454
45- let owned_crates = CrateOwner :: by_owner_kind ( OwnerKind :: User )
46- . inner_join ( crates:: table)
47- . filter ( crate_owners:: owner_id. eq ( user_id) )
48- . select ( ( crates:: id, crates:: name, crate_owners:: email_notifications) )
49- . order ( crates:: name. asc ( ) )
50- . load ( & mut conn)
51- . await ?
55+ let owned_crates = owned_crates
5256 . into_iter ( )
5357 . map ( |( id, name, email_notifications) | OwnedCrate {
5458 id,
0 commit comments