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, /// Repository name (unique within the workspace) pub repo_name: String, } /// Unstar a repository /// /// Removes the current user from the repository's stargazers list. /// Requires read access to the repository. /// /// Effects: /// - User is removed from the repository's stargazers /// - Repository star count is decremented /// /// Returns success message on completion. Idempotent operation (unstarring an unstarred repository is a no-op). #[utoipa::path( delete, path = "/api/v1/workspaces/{workspace_name}/repos/{repo_name}/star", tag = "Repos", operation_id = "repoUnstar", params(PathParams), responses( (status = 200, description = "Repository unstarred successfully.", body = ApiResponse), (status = 401, description = "Authentication required or session expired", body = ApiErrorResponse), (status = 403, description = "Insufficient permissions to access this repository", body = ApiErrorResponse), (status = 404, description = "Repository or workspace not found", body = ApiErrorResponse), (status = 500, description = "Internal server error", body = ApiErrorResponse), ), security( ("session_cookie" = []) ) )] pub async fn unstar_repo( service: web::Data, session: Session, path: web::Path, ) -> Result { service .repo .repo_unstar(&session, &path.workspace_name, &path.repo_name) .await?; Ok(HttpResponse::Ok().json(ApiResponse::new( "Repository unstarred successfully".to_string(), ))) }