TwilioQueueItemHandler
Overview
Handles sending SMS messages and syncing delivery status via the Twilio API. Instantiating this class with TWILIO_ACCOUNT_SID in settings initializes the Twilio client; without it the handler is a no-op.
pull_sms_status
Poll Twilio for messages sent since the queue item's date and update their status.
Signature
pull_sms_status(self, qi)
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| self | yes | |||
| qi | yes |
Source
server/vueda/vdq/handlers.py:249
pull_sms_timeout_only
Check awaiting SMS queue items that have exceeded the timeout window (default 2 hours). Fetches each message's current status from Twilio and transitions timed-out items to timeout if no final status is available.
Signature
pull_sms_timeout_only(self)
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| self | yes |
Source
server/vueda/vdq/handlers.py:269
send_sms
Send an SMS for the given QueueItem via Twilio. The status callback URL carries the item's primary key, so a status update can find the item before VDQ stores the message SID. Transitions the item to await on success, or error on TwilioRestException. A status update that reached the item first keeps the state and result it set.
Signature
send_sms(self, qi)
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| self | yes | |||
| qi | yes |
Source
server/vueda/vdq/handlers.py:195
update_sms_qi
Update a QueueItem based on a Twilio message_status string. Transitions to succeed on delivered and to error on undelivered or failed, from sending as well as from awaiting. Any other status moves a sending item to awaiting when it is in flight (queued, sending, sent), and times out an awaiting item that has waited longer than the configured timeout. Otherwise it changes nothing.
Signature
update_sms_qi(self, queue_item, message_status, message, webhook, error_code)
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| self | yes | |||
| queue_item | yes | |||
| message_status | yes | |||
| message | no | None | ||
| webhook | no | False | ||
| error_code | no | '' |
Source
server/vueda/vdq/handlers.py:303
twilio_client
Source
server/vueda/vdq/handlers.py:177