Emit communication creation event for submitting compliance reports

This commit is contained in:
Eli Ribble 2026-05-20 23:55:45 +00:00
parent 66dc3a171e
commit 75d0283453
No known key found for this signature in database

View file

@ -166,6 +166,7 @@ func PublicReportUpdateCompliance(ctx context.Context, public_id string, report_
return fmt.Errorf("find compliance %d: %w", report.ID, err)
}
// Don't allow modifying of the submission date if it's set
var comm_id int
if compliance_updates.Has(tablepublicreport.Compliance.Submitted) {
if compliance.Submitted != nil {
compliance_updates.Unset(tablepublicreport.Compliance.Submitted)
@ -195,6 +196,7 @@ func PublicReportUpdateCompliance(ctx context.Context, public_id string, report_
return fmt.Errorf("insert communication log entry: %w", err)
}
log.Debug().Int32("id", comm.ID).Msg("inserted new communication")
comm_id = int(comm.ID)
}
}
@ -248,6 +250,13 @@ func PublicReportUpdateCompliance(ctx context.Context, public_id string, report_
if err := txn.Commit(ctx); err != nil {
return fmt.Errorf("commit: %w", err)
}
if comm_id != 0 {
event.Created(
event.TypeCommunication,
report.OrganizationID,
strconv.Itoa(comm_id),
)
}
return nil
}
func PublicReportReporterUpdated(ctx context.Context, org_id int32, report_id string) {