@@ -15,18 +15,19 @@ use crate::views::{
1515} ;
1616use axum:: extract:: Path ;
1717use axum:: Json ;
18+ use axum_extra:: json;
19+ use axum_extra:: response:: ErasedJson ;
1820use chrono:: { Duration , Utc } ;
1921use diesel:: pg:: Pg ;
2022use diesel:: sql_types:: Bool ;
2123use diesel_async:: async_connection_wrapper:: AsyncConnectionWrapper ;
2224use http:: request:: Parts ;
2325use indexmap:: IndexMap ;
24- use serde_json:: Value ;
2526use std:: collections:: { HashMap , HashSet } ;
2627use tokio:: runtime:: Handle ;
2728
2829/// Handles the `GET /api/v1/me/crate_owner_invitations` route.
29- pub async fn list ( app : AppState , req : Parts ) -> AppResult < Json < Value > > {
30+ pub async fn list ( app : AppState , req : Parts ) -> AppResult < ErasedJson > {
3031 let mut conn = app. db_read ( ) . await ?;
3132 let auth = AuthCheck :: only_cookie ( ) . check ( & req, & mut conn) . await ?;
3233 spawn_blocking ( move || {
@@ -59,10 +60,10 @@ pub async fn list(app: AppState, req: Parts) -> AppResult<Json<Value>> {
5960 } )
6061 . collect :: < AppResult < Vec < EncodableCrateOwnerInvitationV1 > > > ( ) ?;
6162
62- Ok ( Json ( json ! ( {
63+ Ok ( json ! ( {
6364 "crate_owner_invitations" : crate_owner_invitations,
6465 "users" : users,
65- } ) ) )
66+ } ) )
6667 } )
6768 . await
6869}
@@ -275,7 +276,7 @@ struct OwnerInvitation {
275276}
276277
277278/// Handles the `PUT /api/v1/me/crate_owner_invitations/:crate_id` route.
278- pub async fn handle_invite ( state : AppState , req : BytesRequest ) -> AppResult < Json < Value > > {
279+ pub async fn handle_invite ( state : AppState , req : BytesRequest ) -> AppResult < ErasedJson > {
279280 let ( parts, body) = req. 0 . into_parts ( ) ;
280281
281282 let crate_invite: OwnerInvitation =
@@ -299,14 +300,14 @@ pub async fn handle_invite(state: AppState, req: BytesRequest) -> AppResult<Json
299300 invitation. decline ( & mut conn) . await ?;
300301 }
301302
302- Ok ( Json ( json ! ( { "crate_owner_invitation" : crate_invite } ) ) )
303+ Ok ( json ! ( { "crate_owner_invitation" : crate_invite } ) )
303304}
304305
305306/// Handles the `PUT /api/v1/me/crate_owner_invitations/accept/:token` route.
306307pub async fn handle_invite_with_token (
307308 state : AppState ,
308309 Path ( token) : Path < String > ,
309- ) -> AppResult < Json < Value > > {
310+ ) -> AppResult < ErasedJson > {
310311 let mut conn = state. db_write ( ) . await ?;
311312 let invitation = CrateOwnerInvitation :: find_by_token ( & token, & mut conn) . await ?;
312313
@@ -315,10 +316,10 @@ pub async fn handle_invite_with_token(
315316 let crate_id = invitation. crate_id ;
316317 invitation. accept ( & mut conn, config) . await ?;
317318
318- Ok ( Json ( json ! ( {
319+ Ok ( json ! ( {
319320 "crate_owner_invitation" : {
320321 "crate_id" : crate_id,
321322 "accepted" : true ,
322323 } ,
323- } ) ) )
324+ } ) )
324325}
0 commit comments