use actix_web::{HttpResponse, web}; use serde::Deserialize; use utoipa::IntoParams; use crate::api::response::{ApiErrorResponse, ApiResponse}; use crate::error::AppError; use crate::models::issues::IssueEvent; 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, } #[derive(Debug, Deserialize, IntoParams)] pub struct QueryParams { /// Maximum number of events to return (default: 50, max: 100) pub limit: Option, /// Number of events to skip for pagination (default: 0) pub offset: Option, } /// List issue events /// /// Returns a chronological timeline of all events for the given issue. /// Events include creation, updates, state changes, assignments, label changes, etc. /// Sorted by creation date (oldest first for timeline display). /// Requires read access to the issue. #[utoipa::path( get, path = "/api/v1/workspaces/{workspace_name}/issues/{number}/events", tag = "Issues", operation_id = "issueListEvents", params(PathParams, QueryParams), responses( (status = 200, description = "Events listed successfully. Returns chronological array of event objects.", body = ApiResponse>), (status = 401, description = "Authentication required or session expired", body = ApiErrorResponse), (status = 403, description = "Insufficient permissions to view this issue", body = ApiErrorResponse), (status = 404, description = "Issue not found", body = ApiErrorResponse), (status = 500, description = "Internal server error", body = ApiErrorResponse), ), security( ("session_cookie" = []) ) )] pub async fn list_events( service: web::Data, session: Session, path: web::Path, query: web::Query, ) -> Result { let events = service .issue .issue_list_events( &session, &path.workspace_name, path.number, query.limit.unwrap_or(50), query.offset.unwrap_or(0), ) .await?; Ok(HttpResponse::Ok().json(ApiResponse::new(events))) }