use actix_web::{HttpResponse, web}; use serde::Deserialize; use utoipa::IntoParams; use crate::api::response::{ApiErrorResponse, ApiResponse}; use crate::error::AppError; use crate::service::AppService; use crate::session::Session; #[derive(Debug, Deserialize, IntoParams)] pub struct PathParams { /// Workspace name (unique identifier) pub workspace_name: String, /// Issue number (unique within the workspace) pub number: i64, /// User ID (UUID) to unassign pub user_id: uuid::Uuid, } /// Unassign a user from an issue /// /// Removes a user from the issue's assignee list. /// Requires write access to the issue (author or workspace member). /// /// Effects: /// - User is removed from the issue's assignees /// - Issue assignee count is decremented /// /// Returns success message on completion. #[utoipa::path( delete, path = "/api/v1/workspaces/{workspace_name}/issues/{number}/assignees/{user_id}", tag = "Issues", operation_id = "issueUnassign", params(PathParams), responses( (status = 200, description = "User unassigned successfully.", body = ApiResponse), (status = 401, description = "Authentication required or session expired", body = ApiErrorResponse), (status = 403, description = "Insufficient permissions to edit this issue", body = ApiErrorResponse), (status = 404, description = "User is not assigned to this issue or not found", body = ApiErrorResponse), (status = 500, description = "Internal server error", body = ApiErrorResponse), ), security( ("session_cookie" = []) ) )] pub async fn unassign_issue( service: web::Data, session: Session, path: web::Path, ) -> Result { service .issue .issue_unassign(&session, &path.workspace_name, path.number, path.user_id) .await?; Ok(HttpResponse::Ok().json(ApiResponse::new("User unassigned".to_string()))) }