Skip to content

Dispatch ​

The relation between a subscriber and a message: when a message is sent, it's dispatched to all subscribers. It's called Email in Postmark.

Columns ​

ColumnTypeNotes
subscriber_idbigintrequired
message_idbigintrequired
sender_idbigintrequired
postmark_message_idstringID of the email in Postmark, used to match webhooks
postmark_message_stream_idstring
sent_attimestampbacks sent
delivered_attimestampbacks delivered, set by the Delivery webhook
opened_attimestampbacks opened, set by the Open webhook
clicked_attimestampbacks clicked
suppressed_attimestampsee Suppressible
suppression_reasonintegerenum, see Suppressible

Unique index on [subscriber_id, message_id].

Included concerns ​

Suppressible

Associations ​

  • belongs_to :subscriber → Subscriber
  • belongs_to :message, counter_cache: :dispatches_count → Message
  • belongs_to :sender → Sender
  • has_one :list, through: :message → List
  • has_one :subscription: the subscriber's subscription to the message's list

Validations ​

  • message uniqueness per subscriber ("should be dispatched once per subscriber")

Timestamp booleans ​

sent, delivered, opened and clicked are backed by their *_at column through time_for_a_boolean, e.g. opened?, opened! (sets opened_at without saving) and opened = false.

Released under the MIT License.