Commit DB transaction after responding
This commit is contained in:
parent
393836a86a
commit
5d03ab0844
2 changed files with 7 additions and 8 deletions
|
|
@ -7,24 +7,19 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
//"github.com/Gleipnir-Technology/bob/dialect/psql"
|
"github.com/rs/zerolog/log"
|
||||||
//"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
|
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/config"
|
||||||
"source.gleipnir.technology/Gleipnir/nidus-sync/db"
|
"source.gleipnir.technology/Gleipnir/nidus-sync/db"
|
||||||
"source.gleipnir.technology/Gleipnir/nidus-sync/db/enums"
|
"source.gleipnir.technology/Gleipnir/nidus-sync/db/enums"
|
||||||
"source.gleipnir.technology/Gleipnir/nidus-sync/db/models"
|
"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"
|
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/csv"
|
||||||
platformemail "source.gleipnir.technology/Gleipnir/nidus-sync/platform/email"
|
platformemail "source.gleipnir.technology/Gleipnir/nidus-sync/platform/email"
|
||||||
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/file"
|
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/file"
|
||||||
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/geocode"
|
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/geocode"
|
||||||
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/mailer"
|
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/mailer"
|
||||||
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/text"
|
"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
|
var waitGroup sync.WaitGroup
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ func respondText(ctx context.Context, log_id int32) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("send response: %w", err)
|
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 {
|
lint.LogOnErrCtx(func(ctx context.Context) error {
|
||||||
return handleWaitingTextJobs(ctx, *src)
|
return handleWaitingTextJobs(ctx, *src)
|
||||||
}, ctx, "handle waiting text jobs")
|
}, ctx, "handle waiting text jobs")
|
||||||
|
|
@ -130,6 +131,7 @@ func respondText(ctx context.Context, log_id int32) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Failed to send unsubscribe acknowledgement.")
|
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
|
return nil
|
||||||
case "reset conversation":
|
case "reset conversation":
|
||||||
err = handleResetConversation(ctx, txn, *src)
|
err = handleResetConversation(ctx, txn, *src)
|
||||||
|
|
@ -141,6 +143,7 @@ func respondText(ctx context.Context, log_id int32) error {
|
||||||
}, ctx, "send text command response")
|
}, ctx, "send text command response")
|
||||||
return fmt.Errorf("reset conversation: %w", err)
|
return fmt.Errorf("reset conversation: %w", err)
|
||||||
}
|
}
|
||||||
|
lint.LogOnErrCtx(func(ctx context.Context) error { return txn.Commit(ctx) }, ctx, "commit after confirm")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// If we've got an open public report from this phone number then we'll let the district respond
|
// 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)
|
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 humans are involved, wait for them.
|
||||||
if len(reports) > 0 {
|
if len(reports) > 0 {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue