-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
842df59
commit 9b130dd
Showing
5 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use crate::db; | ||
use crate::helpers::JsonResponse; | ||
use crate::models; | ||
use actix_web::{delete, web, Responder, Result}; | ||
use sqlx::PgPool; | ||
|
||
#[tracing::instrument(name = "User delete rating.")] | ||
#[delete("/{id}")] | ||
pub async fn user_delete_handler( | ||
path: web::Path<(i32,)>, | ||
pg_pool: web::Data<PgPool>, | ||
) -> Result<impl Responder> { | ||
let rate_id = path.0; | ||
let rating = db::rating::fetch(pg_pool.get_ref(), rate_id) | ||
.await | ||
.map_err(|_err| JsonResponse::<models::Rating>::build().internal_server_error("")) | ||
.and_then(|rating| { | ||
match rating { | ||
Some(rating) if rating.hidden == Some(false) => { Ok(rating) }, | ||
_ => Err(JsonResponse::<models::Rating>::build().not_found("not found")) | ||
} | ||
})?; | ||
|
||
Ok(JsonResponse::build().set_item(rating).ok("OK")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
pub mod add; | ||
pub mod get; | ||
mod edit; | ||
mod delete; | ||
|
||
pub use add::*; | ||
pub use get::*; | ||
pub use edit::*; | ||
pub use delete::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters