Move properties of phones to the phone, not contact_phone
This makes sense because there will naturally be cases where multiple districts have the same phone number mapped to different contacts.
This commit is contained in:
parent
f957dc6982
commit
7b04822a9b
14 changed files with 143 additions and 104 deletions
|
|
@ -159,18 +159,24 @@ func saveReporterEmail(ctx context.Context, txn db.Ex, contact_id int32, email_a
|
|||
return nil
|
||||
}
|
||||
|
||||
func saveReporterPhone(ctx context.Context, txn db.Ex, contact_id int32, phone *types.E164, can_sms bool) error {
|
||||
if phone == nil {
|
||||
func saveReporterPhone(ctx context.Context, txn db.Ex, contact_id int32, number *types.E164, can_sms bool) error {
|
||||
if number == nil {
|
||||
return nil
|
||||
}
|
||||
p, err := querycomms.ContactPhoneInsert(ctx, txn, modelcomms.ContactPhone{
|
||||
_, err := querycomms.PhoneInsertIfNotExists(ctx, txn, modelcomms.Phone{
|
||||
E164: number.PhoneString(),
|
||||
CanSms: can_sms,
|
||||
ConfirmedMessageID: nil,
|
||||
ContactID: contact_id,
|
||||
E164: phone.PhoneString(),
|
||||
IsSubscribed: false,
|
||||
StopMessageID: nil,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("insert phone if not exists: %w", err)
|
||||
}
|
||||
p, err := querycomms.ContactPhoneInsert(ctx, txn, modelcomms.ContactPhone{
|
||||
ContactID: contact_id,
|
||||
E164: number.PhoneString(),
|
||||
IsSubscribed: false,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("contact add phone: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue