File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ pub async fn get(
9595 id : web:: Path < String > ,
9696 auth : Auth ,
9797) -> Result < impl Responder , ApiError > {
98+ let dev = auth. developer ( ) . ok ( ) ;
9899 let mut pool = data
99100 . db ( )
100101 . acquire ( )
@@ -110,6 +111,19 @@ pub async fn get(
110111 . await ?
111112 . ok_or ( ApiError :: NotFound ( format ! ( "Mod '{id}' not found" ) ) ) ?;
112113
114+ let version_statuses = match dev {
115+ None => Some ( vec ! [ ModVersionStatusEnum :: Accepted ] ) ,
116+ Some ( d) => {
117+ if d. admin {
118+ None
119+ } else if developers:: has_access_to_mod ( d. id , & the_mod. id , & mut pool) . await ? {
120+ Some ( vec ! [ ModVersionStatusEnum :: Accepted , ModVersionStatusEnum :: Pending ] )
121+ } else {
122+ Some ( vec ! [ ModVersionStatusEnum :: Accepted ] )
123+ }
124+ }
125+ } ;
126+
113127 the_mod. tags = mod_tags:: get_for_mod ( & the_mod. id , & mut pool)
114128 . await ?
115129 . into_iter ( )
@@ -118,7 +132,7 @@ pub async fn get(
118132 the_mod. developers = developers:: get_all_for_mod ( & the_mod. id , & mut pool) . await ?;
119133 the_mod. versions = mod_versions:: get_for_mod (
120134 & the_mod. id ,
121- Some ( & [ ModVersionStatusEnum :: Accepted ] ) ,
135+ version_statuses . as_deref ( ) ,
122136 & mut pool,
123137 )
124138 . await ?;
You can’t perform that action at this time.
0 commit comments