2026-01-20 17:10:22 +00:00
|
|
|
package background
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
2026-01-25 18:47:22 +00:00
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/comms/text"
|
2026-01-21 03:30:03 +00:00
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/config"
|
2026-01-20 17:10:22 +00:00
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
|
)
|
|
|
|
|
|
2026-01-25 18:47:22 +00:00
|
|
|
var channelJobText chan text.Job
|
2026-01-21 03:30:03 +00:00
|
|
|
|
2026-01-25 18:47:22 +00:00
|
|
|
func ReportSubscriptionConfirmationText(destination text.E164, report_id string) {
|
|
|
|
|
enqueueJobText(text.NewJobReportSubscriptionConfirmation(
|
|
|
|
|
destination,
|
|
|
|
|
report_id,
|
2026-01-26 16:10:30 +00:00
|
|
|
config.PhoneNumberReport,
|
2026-01-25 18:47:22 +00:00
|
|
|
))
|
2026-01-21 03:30:03 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-25 18:47:22 +00:00
|
|
|
func enqueueJobText(job text.Job) {
|
2026-01-21 03:30:03 +00:00
|
|
|
select {
|
|
|
|
|
case channelJobText <- job:
|
|
|
|
|
log.Info().Msg("Enqueued text job")
|
|
|
|
|
default:
|
|
|
|
|
log.Warn().Msg("sms job channel is full, dropping job")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-25 18:47:22 +00:00
|
|
|
func startWorkerText(ctx context.Context, channel chan text.Job) {
|
2026-01-20 17:10:22 +00:00
|
|
|
go func() {
|
|
|
|
|
for {
|
|
|
|
|
select {
|
|
|
|
|
case <-ctx.Done():
|
|
|
|
|
log.Info().Msg("Email worker shutting down.")
|
|
|
|
|
return
|
|
|
|
|
case job := <-channel:
|
2026-01-25 18:47:22 +00:00
|
|
|
text.Handle(ctx, job)
|
2026-01-20 17:10:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
}
|