use crate::{ApiResponse, error::ApiError}; use actix_web::{HttpResponse, Result, web}; use service::AppService; use session::Session; #[utoipa::path( get, path = "/api/issue/{project}/issues/{number}/reactions", params( ("project" = String, Path), ("number" = i64, Path), ), responses( (status = 200, description = "List issue reactions", body = ApiResponse), (status = 401, description = "Unauthorized"), (status = 404, description = "Not found"), ), tag = "Issues" )] pub async fn issue_reaction_list( service: web::Data, session: Session, path: web::Path<(String, i64)>, ) -> Result { let (project, issue_number) = path.into_inner(); let resp = service .issue_reaction_list(project, issue_number, &session) .await?; Ok(ApiResponse::ok(resp).to_response()) } #[utoipa::path( post, path = "/api/issue/{project}/issues/{number}/reactions", params( ("project" = String, Path), ("number" = i64, Path), ), request_body = service::issue::ReactionAddRequest, responses( (status = 200, description = "Add reaction to issue", body = ApiResponse), (status = 401, description = "Unauthorized"), (status = 403, description = "Forbidden"), (status = 404, description = "Not found"), ), tag = "Issues" )] pub async fn issue_reaction_add( service: web::Data, session: Session, path: web::Path<(String, i64)>, body: web::Json, ) -> Result { let (project, issue_number) = path.into_inner(); let resp = service .issue_reaction_add(project, issue_number, body.into_inner(), &session) .await?; Ok(ApiResponse::ok(resp).to_response()) } #[utoipa::path( delete, path = "/api/issue/{project}/issues/{number}/reactions/{reaction}", params( ("project" = String, Path), ("number" = i64, Path), ("reaction" = String, Path), ), responses( (status = 200, description = "Remove reaction from issue"), (status = 401, description = "Unauthorized"), (status = 403, description = "Forbidden"), (status = 404, description = "Not found"), ), tag = "Issues" )] pub async fn issue_reaction_remove( service: web::Data, session: Session, path: web::Path<(String, i64, String)>, ) -> Result { let (project, issue_number, reaction) = path.into_inner(); service .issue_reaction_remove(project, issue_number, reaction, &session) .await?; Ok(ApiResponse::ok(serde_json::json!({ "success": true })).to_response()) }