forked from Roflin/gamenight
28 lines
961 B
Rust
28 lines
961 B
Rust
use actix_web::{delete, web, HttpResponse, Responder};
|
|
use gamenight_database::{DbPool, GetConnection};
|
|
use gamenight_database::gamenight_participants::GamenightParticipant;
|
|
use uuid::Uuid;
|
|
use crate::request::authorization::AuthUser;
|
|
use crate::request::error::ApiError;
|
|
|
|
#[delete("/gamenight/{gamenightId}/participant/{userId}")]
|
|
pub async fn delete_gamenight_participant(
|
|
pool: web::Data<DbPool>,
|
|
_user: AuthUser,
|
|
gamenight_id: web::Path<Uuid>,
|
|
user_id: web::Path<Uuid>
|
|
) -> Result<impl Responder, ApiError> {
|
|
web::block(move || -> Result<usize, ApiError> {
|
|
let mut conn = pool.get_conn();
|
|
let participant = GamenightParticipant {
|
|
gamenight_id: gamenight_id.into_inner(),
|
|
user_id: user_id.into_inner(),
|
|
};
|
|
let x = gamenight_database::gamenight_participants::delete_gamenight_participant(&mut conn, participant)?;
|
|
|
|
Ok(x)
|
|
})
|
|
.await??;
|
|
|
|
Ok(HttpResponse::Ok())
|
|
} |