Initial creation of endpoint to send messages to public reporters

This commit is contained in:
Eli Ribble 2026-03-15 22:38:36 +00:00
parent 9707e8793b
commit cc95c38ab5
No known key found for this signature in database
12 changed files with 240 additions and 20 deletions

View file

@ -23,7 +23,15 @@ import (
"github.com/rs/zerolog/log"
)
type E164 = phonenumbers.PhoneNumber
type E164 struct {
number *phonenumbers.PhoneNumber
}
func NewE164(n *phonenumbers.PhoneNumber) *E164 {
return &E164{
number: n,
}
}
func EnsureInDB(ctx context.Context, ex bob.Executor, destination E164) (err error) {
return ensureInDB(ctx, ex, PhoneString(destination))
@ -96,11 +104,17 @@ func HandleTextMessage(src string, dst string, body string) {
}
func ParsePhoneNumber(input string) (*E164, error) {
return phonenumbers.Parse(input, "US")
n, err := phonenumbers.Parse(input, "US")
if err != nil {
return nil, err
}
return &E164{
number: n,
}, nil
}
func PhoneString(p E164) string {
return phonenumbers.Format(&p, phonenumbers.E164)
return phonenumbers.Format(p.number, phonenumbers.E164)
}
func StoreSources() error {