#11: implement MTA-STS, TLS-RPT & Autoconfig HTTP services
This commit is contained in:
1 parent
c0042ef207
commit
314eb67dda
20 files changed
+1177
-31
No files matched your search
@@ -0,0 +1,47 @@
|
||||
package usecase
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"lambdamail/protocols/internal/application/port"
|
||||
"lambdamail/protocols/internal/domain/entity"
|
||||
)
|
||||
|
||||
type IngestReportsUseCase struct {
|
||||
reportRepo port.ReportRepository
|
||||
}
|
||||
|
||||
func NewIngestReportsUseCase(reportRepo port.ReportRepository) *IngestReportsUseCase {
|
||||
return &IngestReportsUseCase{reportRepo: reportRepo}
|
||||
}
|
||||
|
||||
func (uc *IngestReportsUseCase) IngestDmarc(ctx context.Context, payload []byte) (*entity.DmarcReport, error) {
|
||||
report, err := entity.ParseDmarcXmlReport(payload)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse dmarc report: %w", err)
|
||||
}
|
||||
|
||||
if uc.reportRepo != nil {
|
||||
if err := uc.reportRepo.SaveDmarcReport(ctx, report); err != nil {
|
||||
return nil, fmt.Errorf("save dmarc report: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return report, nil
|
||||
}
|
||||
|
||||
func (uc *IngestReportsUseCase) IngestTlsRpt(ctx context.Context, payload []byte) (*entity.TlsRptReport, error) {
|
||||
report, err := entity.ParseTlsRptReport(payload)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse tls-rpt report: %w", err)
|
||||
}
|
||||
|
||||
if uc.reportRepo != nil {
|
||||
if err := uc.reportRepo.SaveTlsRptReport(ctx, report); err != nil {
|
||||
return nil, fmt.Errorf("save tls-rpt report: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return report, nil
|
||||
}
|
||||
Reference in new issue
Block a user