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:
Eli Ribble 2026-05-22 20:56:22 +00:00
parent f957dc6982
commit 7b04822a9b
No known key found for this signature in database
14 changed files with 143 additions and 104 deletions

View file

@ -36,7 +36,7 @@ func resendInitialText(ctx context.Context, txn db.Ex, dst types.E164) error {
if err != nil {
return fmt.Errorf("Failed to find phone %s: %w", dst, err)
}
err = querycomms.ContactPhoneUpdateStopMessageID(ctx, txn, phone.E164, nil)
err = querycomms.PhoneUpdateStopMessageID(ctx, txn, phone.E164, nil)
if err != nil {
return fmt.Errorf("Failed to clear subscription on phone %s: %w", dst, err)
}
@ -100,17 +100,14 @@ func sendTextComplete(ctx context.Context, job modelcomms.TextJob) error {
if err != nil {
return fmt.Errorf("destination phone from e164: %w", err)
}
log.Debug().Str("phone status", string(destination.Status)).Str("destination", job.Destination).Send()
switch destination.Status {
case modelcomms.Phonestatustype_Unconfirmed:
if destination.ConfirmedMessageID == nil {
err := ensureInitialText(ctx, txn, *dst)
if err != nil {
return fmt.Errorf("Failed to ensure initial text has been sent: %w", err)
}
return nil
//case enums.CommsPhonestatustypeOkToSend:
// allow to drop through
case modelcomms.Phonestatustype_Stopped:
}
if destination.StopMessageID != nil {
lint.LogOnErrCtx(func(ctx context.Context) error {
return resendInitialText(ctx, txn, *dst)
}, ctx, "resend initial text")