Add contacts, rework comms schema

This in a pretty huge change. At a high level we're adding the concept
of a 'contact' which is a person or organization that has zero or more
contact methods (email, phone). This ended up cascading a number of
changes, including critically to the publicreprt schema. In the end it
seemed safer to get to the point where I'm confident we aren't using any
of the old fields for storing reporter information (though I haven't
deleted the columns yet) so I removed the code for defining those
columns.

At this point I think it's not possible for me to regenerate the bob
schema due to the interdependencies between my various schemas, so the
migration is well-and-truly happening.
This commit is contained in:
Eli Ribble 2026-05-15 16:58:28 +00:00
parent 085935fa66
commit f1fe8b4d2b
No known key found for this signature in database
46 changed files with 1127 additions and 633 deletions

View file

@ -11,7 +11,7 @@ import (
modelpublicreport "github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/publicreport/model"
nhttp "github.com/Gleipnir-Technology/nidus-sync/http"
"github.com/Gleipnir-Technology/nidus-sync/platform"
//"github.com/rs/zerolog/log"
//"github.com/rs/zerolog/log":q
)
type communicationR struct {

View file

@ -78,12 +78,8 @@ func (res *complianceR) Create(ctx context.Context, r *http.Request, n publicRep
MapZoom: float32(0.0),
//OrganizationID: ,
//PublicID:
ReporterEmail: "",
ReporterName: "",
ReporterPhone: "",
ReporterPhoneCanSms: true,
ReportType: modelpublicreport.Reporttype_Compliance,
Status: modelpublicreport.Reportstatustype_Reported,
ReportType: modelpublicreport.Reporttype_Compliance,
Status: modelpublicreport.Reportstatustype_Reported,
}
setter_compliance := modelpublicreport.Compliance{
AccessInstructions: "",
@ -166,28 +162,10 @@ func (res *complianceR) Update(ctx context.Context, r *http.Request, prf publicR
report_updater.Set(tablepublicreport.Report.LatlngAccuracyValue)
}
}
var reporter *types.Contact
if prf.Reporter.IsValue() {
reporter := prf.Reporter.MustGet()
if reporter.Email != nil {
//report_setter.ReporterEmail = omit.From(*reporter.Email)
report_updater.Model.ReporterEmail = *reporter.Email
report_updater.Set(tablepublicreport.Report.ReporterEmail)
}
if reporter.Name != nil {
//report_setter.ReporterName = omit.From(*reporter.Name)
report_updater.Model.ReporterName = *reporter.Name
report_updater.Set(tablepublicreport.Report.ReporterName)
}
if reporter.Phone != nil {
//report_setter.ReporterPhone = omit.From(*reporter.Phone)
report_updater.Model.ReporterPhone = *reporter.Phone
report_updater.Set(tablepublicreport.Report.ReporterPhone)
}
if reporter.CanSMS != nil {
//report_setter.ReporterPhoneCanSMS = omit.FromPtr(reporter.CanSMS)
report_updater.Model.ReporterPhoneCanSms = *reporter.CanSMS
report_updater.Set(tablepublicreport.Report.ReporterPhoneCanSms)
}
l := prf.Reporter.MustGet()
reporter = &l
}
var address *types.Address
if prf.Address.IsValue() {
@ -244,7 +222,7 @@ func (res *complianceR) Update(ctx context.Context, r *http.Request, prf publicR
compliance_updater.Model.Submitted = &now
compliance_updater.Set(tablepublicreport.Compliance.Submitted)
}
err = platform.PublicReportUpdateCompliance(ctx, public_id, report_updater, compliance_updater, address, location)
err = platform.PublicReportUpdateCompliance(ctx, public_id, report_updater, compliance_updater, address, location, reporter)
if err != nil {
return nil, nhttp.NewError("platform update report compliance: %w", err)
}