Skip to content

Commit f14ef6b

Browse files
committed
fix: it now compiles
1 parent 39a315a commit f14ef6b

File tree

5 files changed

+15
-24
lines changed

5 files changed

+15
-24
lines changed

src/database/repository/developers.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use crate::types::api::{ApiError, PaginatedData};
2-
use crate::types::models::developer::{ModDeveloper, Developer};
3-
use futures::TryFutureExt;
4-
use sqlx::{PgConnection, Postgres, QueryBuilder};
5-
use std::collections::hash_map::Entry;
2+
use crate::types::models::developer::{Developer, ModDeveloper};
3+
use sqlx::PgConnection;
64
use std::collections::HashMap;
75

86
pub async fn index(
@@ -129,10 +127,7 @@ async fn insert_github(
129127
})?)
130128
}
131129

132-
pub async fn get_one(
133-
id: i32,
134-
conn: &mut PgConnection,
135-
) -> Result<Option<Developer>, ApiError> {
130+
pub async fn get_one(id: i32, conn: &mut PgConnection) -> Result<Option<Developer>, ApiError> {
136131
Ok(sqlx::query_as!(
137132
Developer,
138133
"SELECT
@@ -237,7 +232,7 @@ pub async fn get_all_for_mods(
237232
ApiError::DbError
238233
})?;
239234

240-
let mut ret = HashMap::new();
235+
let mut ret: HashMap<String, Vec<ModDeveloper>> = HashMap::new();
241236

242237
for result_item in result {
243238
ret.entry(result_item.mod_id)
@@ -361,6 +356,7 @@ pub async fn update_status(
361356
dev_id
362357
)
363358
.fetch_one(&mut *conn)
359+
.await
364360
.map_err(|e| {
365361
log::error!("Failed to update developer {}: {}", dev_id, e);
366362
ApiError::DbError
@@ -387,6 +383,7 @@ pub async fn update_profile(
387383
dev_id
388384
)
389385
.fetch_one(&mut *conn)
386+
.await
390387
.map_err(|e| {
391388
log::error!("Failed to update profile for {}: {}", dev_id, e);
392389
ApiError::DbError

src/endpoints/developers.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use actix_web::{delete, get, post, put, web, HttpResponse, Responder};
22
use serde::{Deserialize, Serialize};
3-
use sqlx::Acquire;
43

54
use crate::config::AppData;
65
use crate::database::repository::{auth_tokens, developers, mods};
@@ -9,13 +8,10 @@ use crate::{
98
types::{
109
api::{ApiError, ApiResponse},
1110
models::{
12-
developer::ModDeveloper,
13-
mod_entity::Mod,
14-
mod_version_status::ModVersionStatusEnum,
11+
developer::ModDeveloper, mod_entity::Mod, mod_version_status::ModVersionStatusEnum,
1512
},
1613
},
1714
};
18-
use crate::types::models::developer::Developer;
1915

2016
#[derive(Deserialize, Serialize, Debug, Clone)]
2117
pub struct SimpleDevMod {
@@ -104,10 +100,10 @@ pub async fn add_developer_to_mod(
104100
.await
105101
.or(Err(ApiError::DbAcquireError))?;
106102

107-
if (!mods::exists(&path.id, &mut pool).await?) {
103+
if !mods::exists(&path.id, &mut pool).await? {
108104
return Err(ApiError::NotFound(format!("Mod id {} not found", path.id)));
109105
}
110-
if !(developers::owns_mod(dev.id, &path.id, &mut pool).await?) {
106+
if !developers::owns_mod(dev.id, &path.id, &mut pool).await? {
111107
return Err(ApiError::Forbidden);
112108
}
113109

@@ -136,11 +132,11 @@ pub async fn remove_dev_from_mod(
136132
.await
137133
.or(Err(ApiError::DbAcquireError))?;
138134

139-
if (!mods::exists(&path.id, &mut pool).await) {
135+
if !mods::exists(&path.id, &mut pool).await? {
140136
return Err(ApiError::NotFound(format!("Mod id {} not found", path.id)));
141137
}
142138

143-
if !(developers::owns_mod(dev.id, &path.id, &mut pool).await?) {
139+
if !developers::owns_mod(dev.id, &path.id, &mut pool).await? {
144140
return Err(ApiError::Forbidden);
145141
}
146142

@@ -300,7 +296,7 @@ pub async fn update_developer(
300296
auth.admin()?;
301297

302298
if payload.admin.is_none() && payload.verified.is_none() {
303-
return Ok(HttpResponse::Ok());
299+
return Err(ApiError::BadRequest("Specify at least one param to modify".into()))
304300
}
305301

306302
let mut pool = data
@@ -321,7 +317,7 @@ pub async fn update_developer(
321317
} else {
322318
developers::get_one(path.id, &mut pool)
323319
.await?
324-
.ok_or(ApiError::NotFound("Developer not found".into()))?;
320+
.ok_or(ApiError::NotFound("Developer not found".into()))?
325321
}
326322
};
327323

@@ -334,7 +330,7 @@ pub async fn update_developer(
334330
.await?;
335331

336332
Ok(web::Json(ApiResponse {
337-
error: "".into(),
333+
error: "".to_string(),
338334
payload: result,
339335
}))
340336
}

src/endpoints/mod_versions.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use crate::{
1616
api::{ApiError, ApiResponse},
1717
mod_json::{split_version_and_compare, ModJson},
1818
models::{
19-
developer::ModDeveloper,
2019
mod_entity::{download_geode_file, Mod},
2120
mod_gd_version::{GDVersionEnum, VerPlatform},
2221
mod_version::{self, ModVersion},

src/endpoints/mods.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::events::mod_feature::ModFeaturedEvent;
55
use crate::extractors::auth::Auth;
66
use crate::types::api::{create_download_link, ApiError, ApiResponse};
77
use crate::types::mod_json::ModJson;
8-
use crate::types::models::developer::ModDeveloper;
98
use crate::types::models::incompatibility::Incompatibility;
109
use crate::types::models::mod_entity::{download_geode_file, Mod, ModUpdate};
1110
use crate::types::models::mod_gd_version::{GDVersionEnum, VerPlatform};

src/types/models/stats.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use reqwest::{header::HeaderValue, Client};
55
use serde::{Deserialize, Serialize};
66
use sqlx::PgConnection;
77

8-
use super::{developer::ModDeveloper, mod_entity::Mod};
8+
use super::mod_entity::Mod;
99

1010
#[derive(Deserialize)]
1111
struct GithubReleaseAsset {

0 commit comments

Comments
 (0)