22
33use crate :: app:: AppState ;
44use crate :: auth:: AuthCheck ;
5- use crate :: controllers:: helpers:: ok_true ;
5+ use crate :: controllers:: helpers:: OkResponse ;
66use crate :: controllers:: krate:: CratePath ;
77use crate :: models:: { Crate , Follow } ;
88use crate :: schema:: * ;
99use crate :: util:: errors:: { AppResult , crate_not_found} ;
10- use axum:: response:: Response ;
1110use axum_extra:: json;
1211use axum_extra:: response:: ErasedJson ;
1312use diesel:: prelude:: * ;
@@ -41,7 +40,7 @@ async fn follow_target(
4140 tag = "crates" ,
4241 responses( ( status = 200 , description = "Successful Response" ) ) ,
4342) ]
44- pub async fn follow_crate ( app : AppState , path : CratePath , req : Parts ) -> AppResult < Response > {
43+ pub async fn follow_crate ( app : AppState , path : CratePath , req : Parts ) -> AppResult < OkResponse > {
4544 let mut conn = app. db_write ( ) . await ?;
4645 let user_id = AuthCheck :: default ( ) . check ( & req, & mut conn) . await ?. user_id ( ) ;
4746 let follow = follow_target ( & path. name , & mut conn, user_id) . await ?;
@@ -51,7 +50,7 @@ pub async fn follow_crate(app: AppState, path: CratePath, req: Parts) -> AppResu
5150 . execute ( & mut conn)
5251 . await ?;
5352
54- ok_true ( )
53+ Ok ( OkResponse :: new ( ) )
5554}
5655
5756/// Unfollow a crate.
@@ -66,13 +65,13 @@ pub async fn follow_crate(app: AppState, path: CratePath, req: Parts) -> AppResu
6665 tag = "crates" ,
6766 responses( ( status = 200 , description = "Successful Response" ) ) ,
6867) ]
69- pub async fn unfollow_crate ( app : AppState , path : CratePath , req : Parts ) -> AppResult < Response > {
68+ pub async fn unfollow_crate ( app : AppState , path : CratePath , req : Parts ) -> AppResult < OkResponse > {
7069 let mut conn = app. db_write ( ) . await ?;
7170 let user_id = AuthCheck :: default ( ) . check ( & req, & mut conn) . await ?. user_id ( ) ;
7271 let follow = follow_target ( & path. name , & mut conn, user_id) . await ?;
7372 diesel:: delete ( & follow) . execute ( & mut conn) . await ?;
7473
75- ok_true ( )
74+ Ok ( OkResponse :: new ( ) )
7675}
7776
7877/// Check if a crate is followed.
0 commit comments