feat(email): export send attempt metadata
CI and Deploy / test (pull_request) Failing after 4m32s
CI and Deploy / deploy (pull_request) Has been skipped

Add content-free provider delivery history to encrypted and daily owner exports, exclude payload hashes, and lock in tenant-safe hard-delete cascades.
This commit is contained in:
cesnimda
2026-08-10 00:48:32 +02:00
parent 14f8d4e928
commit aff34cc645
6 changed files with 120 additions and 2 deletions
@@ -2,6 +2,7 @@ using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using JobTrackerApi.Data;
using JobTrackerApi.Models;
using Microsoft.EntityFrameworkCore;
namespace JobTrackerApi.Services;
@@ -61,6 +62,21 @@ public sealed class DailyExportHostedService(
Correspondence = await db.Correspondences.AsNoTracking().Where(message => jobIds.Contains(message.JobApplicationId)).OrderBy(message => message.Date).ToListAsync(cancellationToken),
Attachments = await db.Attachments.AsNoTracking().Where(attachment => jobIds.Contains(attachment.JobApplicationId)).OrderBy(attachment => attachment.UploadDate).ToListAsync(cancellationToken),
Events = await db.JobEvents.AsNoTracking().Where(jobEvent => jobIds.Contains(jobEvent.JobApplicationId)).OrderBy(jobEvent => jobEvent.At).ToListAsync(cancellationToken),
EmailSendAttempts = await db.EmailSendAttempts.AsNoTracking()
.Where(attempt => jobIds.Contains(attempt.JobApplicationId))
.OrderBy(attempt => attempt.CreatedAtUtc)
.Select(attempt => new EmailSendAttemptExport(
attempt.Id,
attempt.JobApplicationId,
attempt.Provider,
attempt.ClientRequestId,
attempt.Status,
attempt.ProviderMessageId,
attempt.FailureCategory,
attempt.CreatedAtUtc,
attempt.StartedAtUtc,
attempt.CompletedAtUtc))
.ToListAsync(cancellationToken),
Rules = await RulesEngine.GetSettings(db, cancellationToken),
};