c5c33f7023
CI / backend (push) Successful in 53s
CI / frontend (push) Successful in 14s
Deploy Staging / deploy (push) Successful in 28s
Security / secrets (push) Successful in 3s
Security / dependencies (push) Successful in 59s
CI / backend (pull_request) Successful in 51s
CI / frontend (pull_request) Successful in 15s
Security / secrets (pull_request) Successful in 3s
Security / dependencies (pull_request) Successful in 56s
26 lines
960 B
C#
26 lines
960 B
C#
using InboxIntel.Application.Abstractions;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace InboxIntel.Api.Controllers;
|
|
|
|
[Microsoft.AspNetCore.RateLimiting.EnableRateLimiting("expensive")] // AUDIT H-2: PDF/CSV generation is costly
|
|
public class ExportController : ApiControllerBase
|
|
{
|
|
private readonly IExportService _export;
|
|
public ExportController(IExportService export) => _export = export;
|
|
|
|
/// <summary>Export an inbox report. format = pdf | csv | json.</summary>
|
|
[HttpGet("report")]
|
|
public async Task<IActionResult> Report([FromQuery] string format = "pdf", CancellationToken ct = default)
|
|
{
|
|
var fmt = format.ToLowerInvariant() switch
|
|
{
|
|
"csv" => ExportFormat.Csv,
|
|
"json" => ExportFormat.Json,
|
|
_ => ExportFormat.Pdf
|
|
};
|
|
var (content, contentType, fileName) = await _export.ExportReportAsync(UserId, fmt, ct);
|
|
return File(content, contentType, fileName);
|
|
}
|
|
}
|