Documentation ¶
Index ¶
Constants ¶
const ( // Subscriber. SubscriberStatusEnabled = "enabled" SubscriberStatusDisabled = "disabled" SubscriberStatusBlackListed = "blacklisted" // Campaign. CampaignStatusDraft = "draft" CampaignStatusScheduled = "scheduled" CampaignStatusRunning = "running" CampaignStatusPaused = "paused" CampaignStatusFinished = "finished" CampaignStatusCancelled = "cancelled" // List. ListTypePrivate = "private" ListTypePublic = "public" // User. UserTypeSuperadmin = "superadmin" UserTypeUser = "user" UserStatusEnabled = "enabled" UserStatusDisabled = "disabled" // BaseTpl is the name of the base template. BaseTpl = "base" // ContentTpl is the name of the compiled message. ContentTpl = "content" )
Enum values for various statuses.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminNotifCallback ¶
AdminNotifCallback is a callback function that's called when a campaign's status changes.
type Base ¶
type Base struct { ID int `db:"id" json:"id"` CreatedAt null.Time `db:"created_at" json:"created_at"` UpdatedAt null.Time `db:"updated_at" json:"updated_at"` }
Base holds common fields shared across models.
type Campaign ¶
type Campaign struct { Base CampaignMeta UUID string `db:"uuid" json:"uuid"` Name string `db:"name" json:"name"` Subject string `db:"subject" json:"subject"` FromEmail string `db:"from_email" json:"from_email"` Body string `db:"body" json:"body,omitempty"` SendAt null.Time `db:"send_at" json:"send_at"` Status string `db:"status" json:"status"` ContentType string `db:"content_type" json:"content_type"` Tags pq.StringArray `db:"tags" json:"tags"` TemplateID int `db:"template_id" json:"template_id"` MessengerID string `db:"messenger" json:"messenger"` // TemplateBody is joined in from templates by the next-campaigns query. TemplateBody string `db:"template_body" json:"-"` Tpl *template.Template `json:"-"` // Pseudofield for getting the total number of subscribers // in searches and queries. Total int `db:"total" json:"-"` }
Campaign represents an e-mail campaign.
type CampaignMeta ¶
type CampaignMeta struct { CampaignID int `db:"campaign_id" json:""` Views int `db:"views" json:"views"` Clicks int `db:"clicks" json:"clicks"` // This is a list of {list_id, name} pairs unlike Subscriber.Lists[] // because lists can be deleted after a campaign is finished, resulting // in null lists data to be returned. For that reason, campaign_lists maintains // campaign-list associations with a historical record of id + name that persist // even after a list is deleted. Lists types.JSONText `db:"lists" json:"lists"` StartedAt null.Time `db:"started_at" json:"started_at"` ToSend int `db:"to_send" json:"to_send"` Sent int `db:"sent" json:"sent"` }
CampaignMeta contains fields tracking a campaign's progress.
type Campaigns ¶
type Campaigns []Campaign
Campaigns represents a slice of Campaigns.
type List ¶
type List struct { Base UUID string `db:"uuid" json:"uuid"` Name string `db:"name" json:"name"` Type string `db:"type" json:"type"` Tags pq.StringArray `db:"tags" json:"tags"` SubscriberCount int `db:"subscriber_count" json:"subscriber_count"` SubscriberID int `db:"subscriber_id" json:"-"` // This is only relevant when querying the lists of a subscriber. SubscriptionStatus string `db:"subscription_status" json:"subscription_status,omitempty"` // Pseudofield for getting the total number of subscribers // in searches and queries. Total int `db:"total" json:"-"` }
List represents a mailing list.
type Subscriber ¶
type Subscriber struct { Base UUID string `db:"uuid" json:"uuid"` Email string `db:"email" json:"email"` Name string `db:"name" json:"name"` Attribs SubscriberAttribs `db:"attribs" json:"attribs"` Status string `db:"status" json:"status"` CampaignIDs pq.Int64Array `db:"campaigns" json:"-"` Lists types.JSONText `db:"lists" json:"lists"` // Pseudofield for getting the total number of subscribers // in searches and queries. Total int `db:"total" json:"-"` }
Subscriber represents an e-mail subscriber.
func (*Subscriber) FirstName ¶
func (s *Subscriber) FirstName() string
FirstName splits the name by spaces and returns the first chunk of the name that's greater than 2 characters in length, assuming that it is the subscriber's first name.
func (*Subscriber) LastName ¶
func (s *Subscriber) LastName() string
LastName splits the name by spaces and returns the last chunk of the name that's greater than 2 characters in length, assuming that it is the subscriber's last name.
type SubscriberAttribs ¶
type SubscriberAttribs map[string]interface{}
SubscriberAttribs is the map of key:value attributes of a subscriber.
func (SubscriberAttribs) Scan ¶
func (s SubscriberAttribs) Scan(src interface{}) error
Scan unmarshals JSON into SubscriberAttribs.
type Subscribers ¶
type Subscribers []Subscriber
Subscribers represents a slice of Subscriber.
func (Subscribers) GetIDs ¶
func (subs Subscribers) GetIDs() []int
GetIDs returns the list of subscriber IDs.