Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyEvent(ctx context.Context, tx *sqlx.Tx, track *Track, session *Session, run *FlowRun, ...) error
- func ApplyMsgCreatedEvent(ctx context.Context, tx *sqlx.Tx, track *Track, session *Session, run *FlowRun, ...) error
- func AssertContactMessagesPresent(t *testing.T, db *sqlx.DB, contactIDs []flows.ContactID, extraWhere string)
- func AssertContactRunsPresent(t *testing.T, db *sqlx.DB, contactIDs []flows.ContactID, flowID FlowID, ...)
- func AssertContactSessionsPresent(t *testing.T, db *sqlx.DB, contactIDs []flows.ContactID, extraWhere string)
- func LoadContacts(ctx context.Context, db *sqlx.DB, session flows.SessionAssets, org *OrgAssets, ...) ([]*flows.Contact, error)
- func MarkCampaignEventFired(ctx context.Context, db *sqlx.DB, fireID int, fired time.Time) error
- func MarkMessagesPending(ctx context.Context, db *sqlx.DB, msgs []*Msg) error
- func MarkMessagesQueued(ctx context.Context, db *sqlx.DB, msgs []*Msg) error
- type Channel
- func (c *Channel) Address() string
- func (c *Channel) Country() string
- func (c *Channel) ID() ChannelID
- func (c *Channel) MatchPrefixes() []string
- func (c *Channel) Name() string
- func (c *Channel) Parent() *assets.ChannelReference
- func (c *Channel) Roles() []assets.ChannelRole
- func (c *Channel) Schemes() []string
- func (c *Channel) TPS() int
- func (c *Channel) Type() ChannelType
- func (c *Channel) UUID() assets.ChannelUUID
- type ChannelID
- type ChannelType
- type ConnectionID
- type ContactURNID
- type ExitType
- type Field
- type FieldUUID
- type Flow
- type FlowID
- type FlowRun
- type Group
- type GroupID
- type Label
- type LabelID
- type Location
- type Msg
- type MsgDirection
- type MsgStatus
- type MsgType
- type MsgVisibility
- type Org
- func (o *Org) DateFormat() utils.DateFormat
- func (o *Org) Extension(name string) json.RawMessage
- func (o *Org) ID() OrgID
- func (o *Org) Languages() utils.LanguageList
- func (o *Org) Now() time.Time
- func (o *Org) RedactionPolicy() utils.RedactionPolicy
- func (o *Org) TimeFormat() utils.TimeFormat
- func (o *Org) Timezone() *time.Location
- type OrgAssets
- func (a *OrgAssets) ChannelByID(channelID ChannelID) *Channel
- func (a *OrgAssets) ChannelByUUID(channelUUID assets.ChannelUUID) *Channel
- func (a *OrgAssets) Channels() ([]assets.Channel, error)
- func (a *OrgAssets) Env() utils.Environment
- func (a *OrgAssets) FieldByUUID(fieldUUID FieldUUID) *Field
- func (a *OrgAssets) Fields() ([]assets.Field, error)
- func (a *OrgAssets) Flow(flowUUID assets.FlowUUID) (assets.Flow, error)
- func (a *OrgAssets) GroupByID(groupID GroupID) *Group
- func (a *OrgAssets) GroupByUUID(groupUUID assets.GroupUUID) *Group
- func (a *OrgAssets) Groups() ([]assets.Group, error)
- func (a *OrgAssets) Labels() ([]assets.Label, error)
- func (a *OrgAssets) Locations() ([]assets.LocationHierarchy, error)
- func (a *OrgAssets) OrgID() OrgID
- func (a *OrgAssets) Resthooks() ([]assets.Resthook, error)
- type OrgID
- type Resthook
- type ResthookID
- type Session
- type SessionID
- type SessionStatus
- type Step
- type Topup
- type TopupID
- type Track
Constants ¶
const ( DirectionIn = MsgDirection("I") DirectionOut = MsgDirection("O") )
const ( VisibilityVisible = MsgVisibility("V") VisibilityArchived = MsgVisibility("A") VisibilityDeleted = MsgVisibility("D") )
const ( TypeInbox = MsgType("I") TypeFlow = MsgType("F") TypeIVR = MsgType("V") TypeUSSD = MsgType("U") )
const ( MsgStatusInitializing = MsgStatus("I") MsgStatusPending = MsgStatus("P") MsgStatusQueued = MsgStatus("Q") MsgStatusWired = MsgStatus("W") MsgStatusSent = MsgStatus("S") MsgStatusHandled = MsgStatus("H") MsgStatusErrored = MsgStatus("E") MsgStatusFailed = MsgStatus("F") MsgStatusResent = MsgStatus("R") )
const ( SessionStatusActive = "A" SessionStatusCompleted = "C" SessionStatusErrored = "E" SessionStatusWaiting = "W" )
const ChannelTypeAndroid = ChannelType("A")
Variables ¶
var ( ExitInterrupted = null.NewString("I", true) ExitCompleted = null.NewString("C", true) ExitExpired = null.NewString("E", true) )
var NilTopupID = TopupID(null.NewInt(0, false))
NilTopupID is our nil value for topup id
Functions ¶
func ApplyEvent ¶
func ApplyEvent(ctx context.Context, tx *sqlx.Tx, track *Track, session *Session, run *FlowRun, e flows.Event) error
ApplyEvent applies the passed in event, IE, creates the db objects required etc..
func ApplyMsgCreatedEvent ¶
func ApplyMsgCreatedEvent(ctx context.Context, tx *sqlx.Tx, track *Track, session *Session, run *FlowRun, event *events.MsgCreatedEvent) error
ApplyMsgCreatedEvent creates the db msg for the passed in event
func AssertContactMessagesPresent ¶ added in v0.0.11
func AssertContactRunsPresent ¶ added in v0.0.11
func AssertContactSessionsPresent ¶ added in v0.0.11
func LoadContacts ¶ added in v0.0.5
func LoadContacts(ctx context.Context, db *sqlx.DB, session flows.SessionAssets, org *OrgAssets, ids []flows.ContactID) ([]*flows.Contact, error)
LoadContacts loads a set of contacts for the passed in ids
func MarkCampaignEventFired ¶
func MarkMessagesPending ¶ added in v0.0.5
MarkMessagesPending marks the passed in messages as pending
Types ¶
type Channel ¶ added in v0.0.5
type Channel struct {
// contains filtered or unexported fields
}
Channel is the mailroom struct that represents channels
func (*Channel) MatchPrefixes ¶ added in v0.0.5
MatchPrefixes returns the prefixes we should also match when determining channel affinity
func (*Channel) Parent ¶ added in v0.0.5
func (c *Channel) Parent() *assets.ChannelReference
Parent returns the UUID of the parent channel to this channel
func (*Channel) Roles ¶ added in v0.0.5
func (c *Channel) Roles() []assets.ChannelRole
Roles returns the roles this channel supports
func (*Channel) TPS ¶ added in v0.0.5
TPS returns the max number of transactions per second this channel supports
func (*Channel) Type ¶ added in v0.0.5
func (c *Channel) Type() ChannelType
Type returns the channel type for this channel
func (*Channel) UUID ¶ added in v0.0.5
func (c *Channel) UUID() assets.ChannelUUID
UUID returns the UUID of this channel
type ChannelType ¶ added in v0.0.5
type ChannelType string
type ConnectionID ¶
type ContactURNID ¶
type ContactURNID int
type Field ¶ added in v0.0.5
type Field struct {
// contains filtered or unexported fields
}
Field is our mailroom type for contact field types
type Flow ¶ added in v0.0.5
type Flow struct {
// contains filtered or unexported fields
}
Flow is the mailroom type for a flow
func (*Flow) Definition ¶ added in v0.0.5
func (f *Flow) Definition() json.RawMessage
Definition returns the definition for this flow
type FlowRun ¶
type FlowRun struct { ID FlowID `db:"id"` UUID flows.RunUUID `db:"uuid"` IsActive bool `db:"is_active"` CreatedOn time.Time `db:"created_on"` ModifiedOn time.Time `db:"modified_on"` ExitedOn *time.Time `db:"exited_on"` ExitType null.String `db:"exit_type"` ExpiresOn *time.Time `db:"expires_on"` TimeoutOn *time.Time `db:"timeout_on"` Responded bool `db:"responded"` // TODO: should this be a complex object that can read / write iself to the DB as JSON? Results string `db:"results"` // TODO: should this be a complex object that can read / write iself to the DB as JSON? Path string `db:"path"` // TODO: should this be a complex object that can read / write iself to the DB as JSON? Events string `db:"events"` CurrentNodeUUID flows.NodeUUID `db:"current_node_uuid"` ContactID flows.ContactID `db:"contact_id"` FlowID FlowID `db:"flow_id"` OrgID OrgID `db:"org_id"` ParentID null.Int `db:"parent_id"` SessionID SessionID `db:"session_id"` StartID null.Int `db:"start_id"` }
FlowRun is the mailroom type for a FlowRun
type Group ¶ added in v0.0.5
type Group struct {
// contains filtered or unexported fields
}
Group is our mailroom type for contact groups
type Label ¶ added in v0.0.5
type Label struct {
// contains filtered or unexported fields
}
Label is our mailroom type for message labels
type Location ¶ added in v0.0.5
type Location struct { Name_ string `json:"name"` Aliases_ []string `json:"aliases"` Children_ []*Location `json:"children"` // contains filtered or unexported fields }
Location is our mailroom type for administrative locations TODO: convert to something less jank when we have real location constructors
type Msg ¶
type Msg struct { ID flows.MsgID `db:"id" json:"id"` UUID flows.MsgUUID `db:"uuid" json:"uuid"` Text string `db:"text" json:"text"` HighPriority bool `db:"high_priority" json:"high_priority"` CreatedOn time.Time `db:"created_on" json:"created_on"` ModifiedOn time.Time `db:"modified_on" json:"modified_on"` SentOn time.Time `db:"sent_on" json:"sent_on"` QueuedOn time.Time `db:"queued_on" json:"queued_on"` Direction MsgDirection `db:"direction" json:"direction"` Status MsgStatus `db:"status" json:"status"` Visibility MsgVisibility `db:"visibility" json:"visibility"` MsgType MsgType `db:"msg_type"` MsgCount int `db:"msg_count" json:"tps_cost"` ErrorCount int `db:"error_count" json:"error_count"` NextAttempt time.Time `db:"next_attempt" json:"next_attempt"` ExternalID null.String `db:"external_id" json:"external_id"` Attachments pq.StringArray `db:"attachments" json:"attachments"` Metadata null.String `db:"metadata" json:"metadata"` ChannelID ChannelID `db:"channel_id" json:"channel_id"` ChannelUUID assets.ChannelUUID ` json:"channel_uuid"` ConnectionID ConnectionID `db:"connection_id"` ContactID flows.ContactID `db:"contact_id" json:"contact_id"` ContactURNID ContactURNID `db:"contact_urn_id" json:"contact_urn_id"` URN urns.URN ` json:"urn"` URNAuth string ` json:"urn_auth,omitempty"` OrgID OrgID `db:"org_id" json:"org_id"` TopUpID TopupID `db:"topup_id"` // contains filtered or unexported fields }
Msg is our type for mailroom messages
type MsgDirection ¶
type MsgDirection string
type MsgVisibility ¶
type MsgVisibility string
type Org ¶ added in v0.0.5
type Org struct {
// contains filtered or unexported fields
}
Environment is mailroom's type for RapidPro orgs. It also implements the utils.Environment interface for GoFlow
func (*Org) DateFormat ¶ added in v0.0.5
func (o *Org) DateFormat() utils.DateFormat
DateFormat returns the date format for this org
func (*Org) Extension ¶ added in v0.0.5
func (o *Org) Extension(name string) json.RawMessage
Extension returns the extension for this org
func (*Org) Languages ¶ added in v0.0.5
func (o *Org) Languages() utils.LanguageList
Languages returns the list of supported languages for this org
func (*Org) RedactionPolicy ¶ added in v0.0.5
func (o *Org) RedactionPolicy() utils.RedactionPolicy
RedactionPolicy returns the redaction policy (are we anonymous) for this org
func (*Org) TimeFormat ¶ added in v0.0.5
func (o *Org) TimeFormat() utils.TimeFormat
TimeFormat returns the time format for this org
type OrgAssets ¶
type OrgAssets struct {
// contains filtered or unexported fields
}
func GetOrgAssets ¶ added in v0.0.5
GetOrgAssets creates or gets org assets for the passed in org
func (*OrgAssets) ChannelByID ¶ added in v0.0.5
func (*OrgAssets) ChannelByUUID ¶ added in v0.0.5
func (a *OrgAssets) ChannelByUUID(channelUUID assets.ChannelUUID) *Channel
func (*OrgAssets) Env ¶ added in v0.0.5
func (a *OrgAssets) Env() utils.Environment
func (*OrgAssets) FieldByUUID ¶ added in v0.0.5
func (*OrgAssets) GroupByUUID ¶ added in v0.0.5
type Resthook ¶ added in v0.0.5
type Resthook struct {
// contains filtered or unexported fields
}
Resthook is the mailroom type for resthooks
func (*Resthook) ID ¶ added in v0.0.5
func (r *Resthook) ID() ResthookID
ID returns the ID of this resthook
func (*Resthook) Subscribers ¶ added in v0.0.5
Subscribers returns the subscribers for this resthook
type ResthookID ¶ added in v0.0.5
type ResthookID int64
ResthookID is our type for the database id of a resthook
type Session ¶
type Session struct { ID SessionID `db:"id"` Status SessionStatus `db:"status"` Responded bool `db:"responded"` Output string `db:"output"` ContactID flows.ContactID `db:"contact_id"` OrgID OrgID `db:"org_id"` CreatedOn time.Time // contains filtered or unexported fields }
Session is the mailroom type for a FlowSession
func WriteSessions ¶ added in v0.0.10
func WriteSessions(ctx context.Context, tx *sqlx.Tx, track *Track, ss []flows.Session) ([]*Session, error)
WriteSessions writes the passed in session to our database, writes any runs that need to be created as well as appying any events created in the session
func (*Session) AddOutboxMsg ¶
AddOutboxMsg adds a message to the outbox for this session
type SessionStatus ¶
type SessionStatus string
type Step ¶
type Step struct { UUID flows.StepUUID `json:"uuid"` NodeUUID flows.NodeUUID `json:"node_uuid"` ArrivedOn time.Time `json:"arrived_on"` ExitUUID flows.ExitUUID `json:"exit_uuid,omitempty"` }
Step represents a single step in a run, this struct is used for serialization to the steps
type Topup ¶ added in v0.0.10
type Topup struct { ID TopupID `db:"id"` Remaining int `db:"remaining"` Expiration time.Time `db:"expires_on"` }
Topup is our internal struct representing an org's topup and expiration date