Files
warmbly/internal/app/consumer/event_remove_email.go
T
Matthew Meszaros 15ef9d4994 feat: add warmup content controls
Add warmup content generation and admin review surfaces, plus mailbox warmup appeal/status APIs.

Track warmup engagement and tampering signals so unsafe mailboxes can be handled by the warmup flow.
2026-06-03 05:05:53 +02:00

32 lines
1.0 KiB
Go

package jobs
import (
"context"
"github.com/warmbly/warmbly/internal/models"
)
// HandleRemoveEmail processes a message removal observed during mailbox sync.
//
// Tampering protection: if the removed message was a warmup email (tracked in
// warmup_received), the recipient deleted pool warmup mail — that harms the
// pool, so we record a tampering strike against the mailbox and ban it from
// warmup once the threshold is crossed. The owner can appeal.
//
// It also drops the local unibox entry for the removed message (best-effort).
func (s *JobsService) HandleRemoveEmail(ctx context.Context, e *models.JobEventRemoveEmail) error {
if s.WarmupRepo != nil {
if rec, _ := s.WarmupRepo.GetWarmupReceived(ctx, e.EmailID, e.ID); rec != nil {
if s.WarmupService != nil {
health, _ := s.WarmupService.RecordTampering(ctx, e.EmailID, rec.MessageID, "deletion")
s.markRiskBandFromWarmupHealth(ctx, e.EmailID, health)
}
}
}
if s.UniboxRepository != nil {
_ = s.UniboxRepository.Delete(ctx, e.UserID, e.ID)
}
return nil
}