From 81e057b900ad5652b20d700f03ed93a955b4c434 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Thu, 16 Apr 2026 17:15:20 +0000 Subject: [PATCH] Add initial work for backgrounding mailer job --- db/enums/enums.bob.go | 5 ++++- platform/background/background.go | 3 +++ platform/compliance.go | 5 +++++ platform/start.go | 3 +++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/db/enums/enums.bob.go b/db/enums/enums.bob.go index 6fb2a61d..b370865d 100644 --- a/db/enums/enums.bob.go +++ b/db/enums/enums.bob.go @@ -1234,6 +1234,7 @@ const ( JobtypeEmailSend Jobtype = "email-send" JobtypeTextRespond Jobtype = "text-respond" JobtypeTextSend Jobtype = "text-send" + JobtypeComplianceMailerSend Jobtype = "compliance-mailer-send" ) func AllJobtype() []Jobtype { @@ -1245,6 +1246,7 @@ func AllJobtype() []Jobtype { JobtypeEmailSend, JobtypeTextRespond, JobtypeTextSend, + JobtypeComplianceMailerSend, } } @@ -1262,7 +1264,8 @@ func (e Jobtype) Valid() bool { JobtypeLabelStudioAudioCreate, JobtypeEmailSend, JobtypeTextRespond, - JobtypeTextSend: + JobtypeTextSend, + JobtypeComplianceMailerSend: return true default: return false diff --git a/platform/background/background.go b/platform/background/background.go index bbe79a6c..2dfbab29 100644 --- a/platform/background/background.go +++ b/platform/background/background.go @@ -15,6 +15,9 @@ import ( func NewAudioTranscode(ctx context.Context, txn bob.Executor, audio_id int32) error { return newJob(ctx, txn, enums.JobtypeAudioTranscode, audio_id) } +func NewComplianceMailer(ctx context.Context, txn bob.Executor, compliance_report_request_id int32) error { + return newJob(ctx, txn, enums.JobtypeComplianceMailerSend, compliance_report_request_id) +} func NewCSVCommit(ctx context.Context, txn bob.Executor, csv_id int32) error { return newJob(ctx, txn, enums.JobtypeCSVCommit, csv_id) } diff --git a/platform/compliance.go b/platform/compliance.go index 9d429129..bc194628 100644 --- a/platform/compliance.go +++ b/platform/compliance.go @@ -9,6 +9,7 @@ import ( "github.com/Gleipnir-Technology/bob/dialect/psql/sm" "github.com/Gleipnir-Technology/nidus-sync/db" "github.com/Gleipnir-Technology/nidus-sync/db/models" + "github.com/Gleipnir-Technology/nidus-sync/platform/background" "github.com/Gleipnir-Technology/nidus-sync/platform/types" "github.com/aarondl/opt/omit" "github.com/aarondl/opt/omitnull" @@ -85,6 +86,10 @@ func ComplianceRequestMailerCreate(ctx context.Context, user User, site_id int32 if err != nil { return 0, fmt.Errorf("create compliance report request: %w", err) } + err = background.NewComplianceMailer(ctx, txn, req.ID) + if err != nil { + return 0, fmt.Errorf("create background compliance mailer job: %w", err) + } txn.Commit(ctx) return req.ID, nil } diff --git a/platform/start.go b/platform/start.go index 34abec84..bae83f76 100644 --- a/platform/start.go +++ b/platform/start.go @@ -19,6 +19,7 @@ import ( "github.com/Gleipnir-Technology/nidus-sync/platform/email" "github.com/Gleipnir-Technology/nidus-sync/platform/file" "github.com/Gleipnir-Technology/nidus-sync/platform/geocode" + "github.com/Gleipnir-Technology/nidus-sync/platform/mailer" "github.com/Gleipnir-Technology/nidus-sync/platform/text" "github.com/jackc/pgx/v5" //"github.com/Gleipnir-Technology/nidus-sync/userfile" @@ -108,6 +109,8 @@ func handleJob(ctx context.Context, txn bob.Executor, job *models.Job) error { switch job.Type { case enums.JobtypeAudioTranscode: return processAudioFile(ctx, txn, job.RowID) + case enums.JobtypeComplianceMailerSend: + return mailer.ComplianceSend(ctx, txn, job.RowID) case enums.JobtypeCSVCommit: return csv.JobCommit(ctx, txn, job.RowID) case enums.JobtypeCSVImport: