fixes errors
This commit is contained in:
@@ -30,7 +30,7 @@ type MaybeForbidden =
|
||||
/// Wraps call to the database query and convert its result as a async HttpResponse
|
||||
fn db_call(
|
||||
pool: AppPool,
|
||||
query: api::ApiActions,
|
||||
query: api::ApiEndpoint,
|
||||
) -> impl Future<Item = HttpResponse, Error = Error> {
|
||||
let conn = pool.get().unwrap();
|
||||
web::block(move || api::execute(&conn, query)).then(|res| match res {
|
||||
@@ -42,7 +42,7 @@ fn db_call(
|
||||
})
|
||||
}
|
||||
|
||||
fn restricted_to_group(id: i32, params: (AppPool, api::ApiActions)) -> MaybeForbidden {
|
||||
fn restricted_to_group(id: i32, params: (AppPool, api::ApiEndpoint)) -> MaybeForbidden {
|
||||
if id != 0 {
|
||||
actix_web::Either::B(HttpResponse::Forbidden().finish())
|
||||
} else {
|
||||
@@ -101,7 +101,7 @@ where
|
||||
}
|
||||
|
||||
fn configure_api(config: &mut web::ServiceConfig) {
|
||||
use api::ApiActions as Q;
|
||||
use api::ApiEndpoint as Q;
|
||||
config.service(
|
||||
web::scope("/api")
|
||||
.wrap(RestrictedAccess)
|
||||
@@ -109,31 +109,31 @@ fn configure_api(config: &mut web::ServiceConfig) {
|
||||
web::scope("/players")
|
||||
.service(
|
||||
web::resource("/")
|
||||
.route(web::get().to_async(|pool| db_call(pool, Q::FetchPlayers)))
|
||||
.route(web::get().to_async(|pool| db_call(pool, Q::PlayerList)))
|
||||
.route(web::post().to_async(
|
||||
|pool, player: web::Json<api::NewPlayer>| {
|
||||
db_call(pool, Q::AddPlayer(player.into_inner()))
|
||||
db_call(pool, Q::PlayerAdd(player.into_inner()))
|
||||
},
|
||||
)),
|
||||
) // List of players
|
||||
.service(
|
||||
web::scope("/{player_id}")
|
||||
.route(
|
||||
/*.route(
|
||||
"/",
|
||||
web::get().to_async(|pool, player: PlayerId| {
|
||||
db_call(pool, Q::FetchPlayer(*player))
|
||||
}),
|
||||
)
|
||||
)*/
|
||||
.route(
|
||||
"/notifications",
|
||||
web::get().to_async(|pool, player: PlayerId| {
|
||||
db_call(pool, Q::FetchNotifications(*player))
|
||||
db_call(pool, Q::PlayerNotifications(*player))
|
||||
}),
|
||||
)
|
||||
.service(
|
||||
web::resource("/claims")
|
||||
.route(web::get().to_async(|pool, player: PlayerId| {
|
||||
db_call(pool, Q::FetchPlayerClaims(*player))
|
||||
db_call(pool, Q::PlayerClaims(*player))
|
||||
}))
|
||||
.route(web::post().to_async(
|
||||
|pool, (player, data): (PlayerId, IdList)| {
|
||||
@@ -146,14 +146,14 @@ fn configure_api(config: &mut web::ServiceConfig) {
|
||||
//.route(web::get().to_async(...))
|
||||
.route(web::put().to_async(
|
||||
|pool, (player, data): (PlayerId, web::Json<f64>)| {
|
||||
db_call(pool, Q::UpdateWealth(*player, *data))
|
||||
db_call(pool, Q::PlayerUpdateWealth(*player, *data))
|
||||
},
|
||||
)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/loot")
|
||||
.route(web::get().to_async(|pool, player: PlayerId| {
|
||||
db_call(pool, Q::FetchLoot(*player))
|
||||
db_call(pool, Q::PlayerLoot(*player))
|
||||
}))
|
||||
.route(web::put().to_async(
|
||||
move |pool, (player, data): (PlayerId, BuySellParams)| {
|
||||
@@ -184,25 +184,25 @@ fn configure_api(config: &mut web::ServiceConfig) {
|
||||
)
|
||||
.route(
|
||||
"/claims",
|
||||
web::get().to_async(|pool| db_call(pool, Q::FetchClaims)),
|
||||
web::get().to_async(|pool| db_call(pool, Q::ClaimsList)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/shop")
|
||||
.route(web::get().to_async(|pool| db_call(pool, Q::FetchShopInventory)))
|
||||
.route(web::get().to_async(|pool| db_call(pool, Q::ShopList)))
|
||||
.route(
|
||||
web::post().to_async(|pool, items: web::Json<api::ItemList>| {
|
||||
db_call(pool, Q::RefreshShopInventory(items.into_inner()))
|
||||
db_call(pool, Q::RefreshShop(items.into_inner()))
|
||||
}),
|
||||
),
|
||||
)
|
||||
.service(
|
||||
web::resource("/items")
|
||||
.route(
|
||||
web::get().to_async(move |pool: AppPool| db_call(pool, Q::FetchInventory)),
|
||||
web::get().to_async(move |pool: AppPool| db_call(pool, Q::InventoryList)),
|
||||
)
|
||||
.route(web::post().to_async(
|
||||
move |pool: AppPool, items: web::Json<Vec<String>>| {
|
||||
db_call(pool, Q::CheckItemList(items.into_inner()))
|
||||
db_call(pool, Q::InventoryCheck(items.into_inner()))
|
||||
},
|
||||
)),
|
||||
),
|
||||
@@ -277,8 +277,8 @@ fn enter_session(id: Identity, pool: AppPool) -> impl Future<Item = HttpResponse
|
||||
api::execute(
|
||||
&conn,
|
||||
match logged {
|
||||
SessionKind::Player(id) => api::ApiActions::FetchPlayer(id),
|
||||
SessionKind::Admin => api::ApiActions::FetchPlayers,
|
||||
SessionKind::Player(id) => api::ApiEndpoint::PlayerFetch(id),
|
||||
SessionKind::Admin => api::ApiEndpoint::PlayerList,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user