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
|
|
@ -41,7 +41,7 @@ func HandleTextMessage(ctx context.Context, source string, destination string, c
|
|||
if err != nil {
|
||||
return fmt.Errorf("ensure source in DB: %w", err)
|
||||
}
|
||||
is_visible_to_llm := s.Status != modelcomms.Phonestatustype_Unconfirmed
|
||||
is_visible_to_llm := s.ConfirmedMessageID != nil
|
||||
|
||||
l, err := querycomms.TextLogInsert(ctx, txn, modelcomms.TextLog{
|
||||
Content: content,
|
||||
|
|
@ -83,17 +83,17 @@ func respondText(ctx context.Context, log_id int32) error {
|
|||
return fmt.Errorf("parse source: %w", err)
|
||||
}
|
||||
|
||||
contact_phone, err := querycomms.ContactPhoneFromE164(ctx, txn, src.PhoneString())
|
||||
phone, err := querycomms.PhoneFromE164(ctx, txn, src.PhoneString())
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to get contact phone")
|
||||
}
|
||||
|
||||
body_l := strings.TrimSpace(strings.ToLower(l.Content))
|
||||
// If the user isn't confirmed for sending regular texts ensure they get a reprompt
|
||||
if contact_phone.ConfirmedMessageID == nil {
|
||||
if phone.ConfirmedMessageID == nil {
|
||||
switch body_l {
|
||||
case "yes":
|
||||
err = querycomms.ContactPhoneUpdateConfirmedMessageID(ctx, txn, src.PhoneString(), &l.ID)
|
||||
err = querycomms.PhoneUpdateConfirmedMessageID(ctx, txn, src.PhoneString(), &l.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("set phone confirmed message ID: %w", err)
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ func respondText(ctx context.Context, log_id int32) error {
|
|||
}
|
||||
switch body_l {
|
||||
case "stop":
|
||||
err = querycomms.ContactPhoneUpdateStopMessageID(ctx, txn, src.PhoneString(), &l.ID)
|
||||
err = querycomms.PhoneUpdateStopMessageID(ctx, txn, src.PhoneString(), &l.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("set phone stop message ID: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue