Refuse to send compliance letters to addresses without a postal code
This commit is contained in:
parent
e45e05f337
commit
797067ee38
2 changed files with 14 additions and 0 deletions
|
|
@ -33,6 +33,13 @@ func ComplianceRequestMailerCreate(ctx context.Context, user User, site_id int32
|
|||
if site.OrganizationID != user.Organization.ID {
|
||||
return 0, fmt.Errorf("permission denied")
|
||||
}
|
||||
address, err := models.FindAddress(ctx, txn, site.AddressID)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("find address %d: %w", site.AddressID, err)
|
||||
}
|
||||
if address.PostalCode == "" {
|
||||
return 0, fmt.Errorf("address %d does not have a postal code", address.ID)
|
||||
}
|
||||
features, err := models.Features.Query(
|
||||
models.SelectWhere.Features.SiteID.EQ(site.ID),
|
||||
).All(ctx, txn)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ import (
|
|||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
// This is the entrypoint for the backend job of sending a compliance mailer
|
||||
// It should only return errors for programmer-level errors we want retried on restart
|
||||
// Not for normal issues
|
||||
func ComplianceSend(ctx context.Context, row_id int32) error {
|
||||
bxn := db.PGInstance.BobDB
|
||||
compliance_req, err := models.FindComplianceReportRequest(ctx, bxn, row_id)
|
||||
|
|
@ -47,6 +50,10 @@ func ComplianceSend(ctx context.Context, row_id int32) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("find address: %w", err)
|
||||
}
|
||||
if address.PostalCode == "" {
|
||||
log.Warn().Int32("id", address.ID).Msg("dropping mailer job because the address has no postal code")
|
||||
return nil
|
||||
}
|
||||
|
||||
organization, err := models.FindOrganization(ctx, bxn, site.OrganizationID)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue