Emit communication updated events when reports change
Some checks failed
/ golint (push) Failing after 10s

This commit is contained in:
Eli Ribble 2026-05-21 04:26:07 +00:00
parent 594bf33b0a
commit d120ed05f2
No known key found for this signature in database
4 changed files with 36 additions and 7 deletions

View file

@ -85,7 +85,8 @@ func PublicReportByIDWater(ctx context.Context, report_id string, is_public bool
return &result, err
}
func PublicReportInvalid(ctx context.Context, user User, public_id string) error {
report, err := querypublicreport.ReportFromPublicID(ctx, db.PGInstance.PGXPool, public_id)
txn := db.PGInstance.PGXPool
report, err := querypublicreport.ReportFromPublicID(ctx, txn, public_id)
if err != nil {
return fmt.Errorf("query report existence: %w", err)
}
@ -102,10 +103,15 @@ func PublicReportInvalid(ctx context.Context, user User, public_id string) error
report_updater.Set(tablepublicreport.Report.ReviewerID)
report_updater.Model.Status = modelpublicreport.Reportstatustype_Invalidated
report_updater.Set(tablepublicreport.Report.Status)
err = report_updater.Execute(ctx, db.PGInstance.PGXPool, report.ID)
err = report_updater.Execute(ctx, txn, report.ID)
log.Info().Int32("id", report.ID).Msg("Report marked as invalid")
event.Updated(event.TypeRMOPublicReport, user.Organization.ID, public_id)
comm, err := querypublic.CommunicationFromReportID(ctx, txn, int64(report.ID))
if err != nil {
return fmt.Errorf("communication from report ID %d: %w", report.ID, err)
}
event.Updated(event.TypeCommunication, user.Organization.ID, strconv.Itoa(int(comm.ID)))
return nil
}
@ -260,9 +266,6 @@ func PublicReportUpdateCompliance(ctx context.Context, public_id string, report_
}
return nil
}
func PublicReportReporterUpdated(ctx context.Context, org_id int32, report_id string) {
event.Updated(event.TypeRMOPublicReport, org_id, report_id)
}
func PublicReportsForOrganization(ctx context.Context, org_id int32, is_public bool) ([]types.PublicReport, error) {
return publicreport.UnreviewedForOrganization(ctx, db.PGInstance.PGXPool, int64(org_id), is_public)
}