Commit DB transaction after responding

This commit is contained in:
Eli Ribble 2026-05-22 23:43:49 +00:00
parent 393836a86a
commit 5d03ab0844
No known key found for this signature in database
2 changed files with 7 additions and 8 deletions

View file

@ -7,24 +7,19 @@ import (
"sync"
"time"
//"github.com/Gleipnir-Technology/bob/dialect/psql"
//"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
"github.com/rs/zerolog/log"
bobpgx "github.com/stephenafamo/bob/drivers/pgx"
commsemail "source.gleipnir.technology/Gleipnir/nidus-sync/comms/email"
"source.gleipnir.technology/Gleipnir/nidus-sync/config"
"source.gleipnir.technology/Gleipnir/nidus-sync/db"
"source.gleipnir.technology/Gleipnir/nidus-sync/db/enums"
"source.gleipnir.technology/Gleipnir/nidus-sync/db/models"
//"source.gleipnir.technology/Gleipnir/nidus-sync/platform/background"
commsemail "source.gleipnir.technology/Gleipnir/nidus-sync/comms/email"
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/csv"
platformemail "source.gleipnir.technology/Gleipnir/nidus-sync/platform/email"
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/file"
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/geocode"
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/mailer"
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/text"
//"source.gleipnir.technology/Gleipnir/nidus-sync/userfile"
//"github.com/google/uuid"
"github.com/rs/zerolog/log"
bobpgx "github.com/stephenafamo/bob/drivers/pgx"
)
var waitGroup sync.WaitGroup

View file

@ -104,6 +104,7 @@ func respondText(ctx context.Context, log_id int32) error {
if err != nil {
return fmt.Errorf("send response: %w", err)
}
lint.LogOnErrCtx(func(ctx context.Context) error { return txn.Commit(ctx) }, ctx, "commit after confirm")
lint.LogOnErrCtx(func(ctx context.Context) error {
return handleWaitingTextJobs(ctx, *src)
}, ctx, "handle waiting text jobs")
@ -130,6 +131,7 @@ func respondText(ctx context.Context, log_id int32) error {
if err != nil {
log.Error().Err(err).Msg("Failed to send unsubscribe acknowledgement.")
}
lint.LogOnErrCtx(func(ctx context.Context) error { return txn.Commit(ctx) }, ctx, "commit after confirm")
return nil
case "reset conversation":
err = handleResetConversation(ctx, txn, *src)
@ -141,6 +143,7 @@ func respondText(ctx context.Context, log_id int32) error {
}, ctx, "send text command response")
return fmt.Errorf("reset conversation: %w", err)
}
lint.LogOnErrCtx(func(ctx context.Context) error { return txn.Commit(ctx) }, ctx, "commit after confirm")
return nil
}
// If we've got an open public report from this phone number then we'll let the district respond
@ -166,6 +169,7 @@ func respondText(ctx context.Context, log_id int32) error {
}
event.Updated(event.TypeRMOPublicReport, report.OrganizationID, report.PublicID)
}
lint.LogOnErrCtx(func(ctx context.Context) error { return txn.Commit(ctx) }, ctx, "commit after confirm")
// If humans are involved, wait for them.
if len(reports) > 0 {
return nil