Emit communication updated events when reports change
Some checks failed
/ golint (push) Failing after 10s
Some checks failed
/ golint (push) Failing after 10s
This commit is contained in:
parent
594bf33b0a
commit
d120ed05f2
4 changed files with 36 additions and 7 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"source.gleipnir.technology/Gleipnir/nidus-sync/db"
|
||||
modelcomms "source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/comms/model"
|
||||
modelpublic "source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/public/model"
|
||||
|
|
@ -15,7 +16,6 @@ import (
|
|||
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/email"
|
||||
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/text"
|
||||
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/types"
|
||||
//"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func DistrictForReport(ctx context.Context, report_id string) (modelpublic.Organization, error) {
|
||||
|
|
@ -89,11 +89,13 @@ func SaveReporter(ctx context.Context, txn db.Ex, report modelpublicreport.Repor
|
|||
if err != nil {
|
||||
return contact, fmt.Errorf("contact insert: %w", err)
|
||||
}
|
||||
log.Debug().Str("name", name).Int32("id", contact.ID).Msg("new contact inserted")
|
||||
} else {
|
||||
contact, err = querycomms.ContactFromID(ctx, txn, int64(*report.ReporterContactID))
|
||||
if err != nil {
|
||||
return contact, fmt.Errorf("contact query: %w", err)
|
||||
}
|
||||
log.Debug().Str("name", name).Str("old name", contact.Name).Int32("id", contact.ID).Msg("contact updated")
|
||||
if name != "" && contact.Name != name {
|
||||
err = querycomms.ContactUpdateName(ctx, txn, int64(contact.ID), name)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue