nidus-sync/platform/text/job.go
Eli Ribble f1fe8b4d2b
Add contacts, rework comms schema
This in a pretty huge change. At a high level we're adding the concept
of a 'contact' which is a person or organization that has zero or more
contact methods (email, phone). This ended up cascading a number of
changes, including critically to the publicreprt schema. In the end it
seemed safer to get to the point where I'm confident we aren't using any
of the old fields for storing reporter information (though I haven't
deleted the columns yet) so I removed the code for defining those
columns.

At this point I think it's not possible for me to regenerate the bob
schema due to the interdependencies between my various schemas, so the
migration is well-and-truly happening.
2026-05-15 16:58:28 +00:00

38 lines
1 KiB
Go

package text
import (
"context"
"fmt"
"github.com/Gleipnir-Technology/nidus-sync/db"
querycomms "github.com/Gleipnir-Technology/nidus-sync/db/query/comms"
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
//"github.com/rs/zerolog/log"
)
func JobRespond(ctx context.Context, log_id int32) error {
return respondText(ctx, log_id)
}
func JobSend(ctx context.Context, job_id int32) error {
bxn := db.PGInstance.PGXPool
job, err := querycomms.TextJobFromID(ctx, bxn, int64(job_id))
if err != nil {
return fmt.Errorf("find text: %w", err)
}
//log.Debug().Int32("job.id", job.ID).Msg("completing text job")
return sendTextComplete(ctx, job)
}
func handleWaitingTextJobs(ctx context.Context, dst types.E164) error {
bxn := db.PGInstance.PGXPool
jobs, err := querycomms.TextJobsWaitingFromDestination(ctx, bxn, dst.PhoneString())
if err != nil {
return fmt.Errorf("query jobs: %w", err)
}
for _, job := range jobs {
err = sendTextComplete(ctx, job)
if err != nil {
return fmt.Errorf("send text complete: %w", err)
}
}
return nil
}