models

package
v0.0.71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2018 License: AGPL-3.0 Imports: 29 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// OffsetMinute means our offset is in minutes
	OffsetMinute = OffsetUnit("M")

	// OffsetHour means our offset is in hours
	OffsetHour = OffsetUnit("H")

	// OffsetDay means our offset is in days
	OffsetDay = OffsetUnit("D")

	// OffsetWeek means our offset is in weeks
	OffsetWeek = OffsetUnit("W")

	// NilDeliveryHour is our constant for not having a set delivery hour
	NilDeliveryHour = -1

	// StartModeInterrupt means the flow for this campaign event should interrupt other flows
	StartModeInterrupt = StartMode("I")

	// StartModeSkip means the flow should be skipped if the user is active in another flow
	StartModeSkip = StartMode("S")

	// StartModePassive means the flow should be started without interrupting the user in other flows
	StartModePassive = StartMode("P")
)
View Source
const (
	DirectionIn  = MsgDirection("I")
	DirectionOut = MsgDirection("O")
)
View Source
const (
	VisibilityVisible  = MsgVisibility("V")
	VisibilityArchived = MsgVisibility("A")
	VisibilityDeleted  = MsgVisibility("D")
)
View Source
const (
	TypeInbox = MsgType("I")
	TypeFlow  = MsgType("F")
	TypeIVR   = MsgType("V")
	TypeUSSD  = MsgType("U")
)
View Source
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")
)
View Source
const (
	SessionStatusActive    = "A"
	SessionStatusCompleted = "C"
	SessionStatusErrored   = "E"
	SessionStatusWaiting   = "W"
	SessionStatusExpired   = "X"
)
View Source
const (
	CatchallTriggerType        = TriggerType("C")
	KeywordTriggerType         = TriggerType("K")
	MissedCallTriggerType      = TriggerType("M")
	NewConversationTriggerType = TriggerType("N")
	ReferralTriggerType        = TriggerType("R")
	CallTriggerType            = TriggerType("V")

	MatchFirst = "F"
	MatchOnly  = "O"
)
View Source
const ChannelTypeAndroid = ChannelType("A")
View Source
const NilBroadcastID = BroadcastID(0)
View Source
const (
	NilContactID = flows.ContactID(0)
)
View Source
const NilFlowRunID = FlowRunID(0)

Variables

View Source
var (
	ExitInterrupted = null.NewString("I", true)
	ExitCompleted   = null.NewString("C", true)
	ExitExpired     = null.NewString("E", true)
)
View Source
var NilChannelID = ChannelID(0)
View Source
var NilStartID = StartID{null.NewInt(0, false)}

NilStartID is our constant for a nil start id

View Source
var NilTopupID = TopupID(null.NewInt(0, false))

NilTopupID is our nil value for topup id

View Source
var NilURNID = URNID(0)

Functions

func AddContactsToGroups added in v0.0.38

func AddContactsToGroups(ctx context.Context, tx Queryer, adds []*GroupAdd) error

AddContactsToGroups fires a bulk SQL query to remove all the contacts in the passed in groups

func AddEventFires added in v0.0.38

func AddEventFires(ctx context.Context, tx Queryer, adds []*FireAdd) error

AddEventFires adds the passed in event fires to our db

func AddMsgLabels added in v0.0.53

func AddMsgLabels(ctx context.Context, tx *sqlx.Tx, adds []*MsgLabelAdd) error

AddMsgLabels inserts the passed in msg labels to our db

func ApplyEvent

func ApplyEvent(ctx context.Context, tx *sqlx.Tx, rp *redis.Pool, org *OrgAssets, session *Session, e flows.Event) error

ApplyEvent applies the passed in event, IE, creates the db objects required etc..

func ApplyPostEventHooks added in v0.0.17

func ApplyPostEventHooks(ctx context.Context, tx *sqlx.Tx, rp *redis.Pool, org *OrgAssets, sessions []*Session) error

ApplyPostEventHooks runs through all the post event hooks for the passed in sessions and applies their events

func ApplyPreEventHooks added in v0.0.17

func ApplyPreEventHooks(ctx context.Context, tx *sqlx.Tx, rp *redis.Pool, org *OrgAssets, sessions []*Session) error

ApplyPreEventHooks runs through all the pre event hooks for the passed in sessions and applies their events

func BulkSQL added in v0.0.22

func BulkSQL(ctx context.Context, label string, tx Queryer, sql string, vs []interface{}) error

func CalculateDynamicGroups added in v0.0.58

func CalculateDynamicGroups(ctx context.Context, tx Queryer, org *OrgAssets, contact *flows.Contact) error

CalculateDynamicGroups recalculates all the dynamic groups for the passed in contact, recalculating campaigns as necessary based on those group changes.

func ContactIDsForGroupIDs added in v0.0.60

func ContactIDsForGroupIDs(ctx context.Context, tx Queryer, groupIDs []GroupID) ([]flows.ContactID, error)

ContactIDsForGroupIDs returns the unique contacts that are in the passed in groups

func ContactIDsFromReferences added in v0.0.58

func ContactIDsFromReferences(ctx context.Context, tx Queryer, org *OrgAssets, refs []*flows.ContactReference) ([]flows.ContactID, error)

ContactIDsFromReferences queries the contacts for the passed in org, returning the contact ids for the references

func ContactIDsFromURNs added in v0.0.58

func ContactIDsFromURNs(ctx context.Context, db *sqlx.DB, org *OrgAssets, assets flows.SessionAssets, us []urns.URN) (map[urns.URN]flows.ContactID, error)

ContactIDsFromURNs will fetch or create the contacts for the passed in URNs, returning a list the same length as the passed in URNs with the ids of the contacts. There is no guarantee in the order of the ids returned

func CreateContact added in v0.0.58

func CreateContact(ctx context.Context, db *sqlx.DB, org *OrgAssets, assets flows.SessionAssets, urn urns.URN) (flows.ContactID, error)

CreateContact creates a new contact for the passed in org with the passed in URNs

func DeleteEventFires added in v0.0.27

func DeleteEventFires(ctx context.Context, db *sqlx.DB, fires []*EventFire) error

DeleteEventFires deletes all event fires passed in (used when an event has been marked as inactive)

func DeleteUnfiredContactEvents added in v0.0.58

func DeleteUnfiredContactEvents(ctx context.Context, tx Queryer, contactID flows.ContactID) error

DeleteUnfiredContactEvents deletes all unfired event fires for the passed in contact

func DeleteUnfiredEventFires added in v0.0.38

func DeleteUnfiredEventFires(ctx context.Context, tx *sqlx.Tx, removes []*FireDelete) error

DeleteUnfiredEventFires removes event fires for the passed in event and contact

func FindActiveRunOverlap added in v0.0.27

func FindActiveRunOverlap(ctx context.Context, db *sqlx.DB, contacts []flows.ContactID) ([]flows.ContactID, error)

FindActiveRunOverlap returns the list of contact ids which overlap with those passed in which are active in any other flows.

func FindFlowStartedOverlap added in v0.0.27

func FindFlowStartedOverlap(ctx context.Context, db *sqlx.DB, flowID FlowID, contacts []flows.ContactID) ([]flows.ContactID, error)

FindFlowStartedOverlap returns the list of contact ids which overlap with those passed in and which have been in the flow passed in.

func FlushCache added in v0.0.38

func FlushCache()

FlushCache clears our entire org cache

func GetSessionAssets added in v0.0.38

func GetSessionAssets(org *OrgAssets) (flows.SessionAssets, error)

GetSessionAssets returns a goflow session assets object for the parred in org assets

func InsertMessages added in v0.0.38

func InsertMessages(ctx context.Context, tx Queryer, msgs []*Msg) error

InsertMessages inserts the passed in messages in a single query

func InterruptContactRuns added in v0.0.27

func InterruptContactRuns(ctx context.Context, tx *sqlx.Tx, contactIDs []flows.ContactID, now time.Time) error

InterruptContactRuns interrupts all runs and sesions that exist for the passed in list of contacts

func MarkEventsFired added in v0.0.19

func MarkEventsFired(ctx context.Context, tx Queryer, fires []*EventFire, fired time.Time) error

MarkEventsFired sets the fired date on all the passed in event fires and updates the associated rows in the database

func MarkMessagesPending added in v0.0.5

func MarkMessagesPending(ctx context.Context, tx *sqlx.Tx, msgs []*Msg) error

MarkMessagesPending marks the passed in messages as pending

func MarkMessagesQueued added in v0.0.2

func MarkMessagesQueued(ctx context.Context, tx *sqlx.Tx, msgs []*Msg) error

MarkMessagesQueued marks the passed in messages as queued

func MarkStartComplete added in v0.0.27

func MarkStartComplete(ctx context.Context, db *sqlx.DB, startID StartID) error

MarkStartComplete sets the status for the passed in flow start

func MarkStartStarted added in v0.0.28

func MarkStartStarted(ctx context.Context, db *sqlx.DB, startID StartID, contactCount int) error

MarkStartStarted sets the status for the passed in flow start to S and updates the contact count on it

func NewSessionAssets added in v0.0.51

func NewSessionAssets(org *OrgAssets) (flows.SessionAssets, error)

NewSessionAssets creates new sessions assets, returning the result

func RegisterEventHook added in v0.0.38

func RegisterEventHook(eventType string, handler EventHandler)

RegisterEventHook registers the passed in handler as being interested in the passed in type

func RemoveContactsFromGroups added in v0.0.38

func RemoveContactsFromGroups(ctx context.Context, tx Queryer, removals []*GroupRemove) error

RemoveContactsFromGroups fires a bulk SQL query to remove all the contacts in the passed in groups

func RunExpiration added in v0.0.66

func RunExpiration(ctx context.Context, db *sqlx.DB, runID FlowRunID) (time.Time, error)

RunExpiration looks up the run expiration for the passed in run

func StopContact added in v0.0.38

func StopContact(ctx context.Context, tx *sqlx.Tx, orgID OrgID, contactID flows.ContactID) error

StopContact stops the contact with the passed in id, removing them from all groups and setting their state to stopped.

func UnsubscribeResthooks added in v0.0.38

func UnsubscribeResthooks(ctx context.Context, tx *sqlx.Tx, unsubs []*ResthookUnsubscribe) error

UnsubscribeResthooks unsubscribles all the resthooks passed in

func UpdateContactModifiedOn added in v0.0.48

func UpdateContactModifiedOn(ctx context.Context, tx Queryer, contactIDs []flows.ContactID) error

UpdateContactModifiedOn updates modified on on the passed in contact

func UpdateContactURNs added in v0.0.48

func UpdateContactURNs(ctx context.Context, tx Queryer, org *OrgAssets, changes []*ContactURNsChanged) error

UpdateContactURNs updates the contact urns in our database to match the passed in changes

func UpdateMessage added in v0.0.38

func UpdateMessage(ctx context.Context, tx Queryer, msgID flows.MsgID, status MsgStatus, visibility MsgVisibility, msgType MsgType, topup TopupID) error

UpdateMessage updates the passed in message status, visibility and msg type

Types

type Broadcast added in v0.0.60

type Broadcast struct {
	// contains filtered or unexported fields
}

Broadcast represents a broadcast that needs to be sent

func NewBroadcastFromEvent added in v0.0.60

func NewBroadcastFromEvent(ctx context.Context, tx Queryer, org *OrgAssets, event *events.BroadcastCreatedEvent) (*Broadcast, error)

NewBroadcastFromEvent creates a broadcast object from the passed in broadcast event

func (*Broadcast) ContactIDs added in v0.0.60

func (b *Broadcast) ContactIDs() []flows.ContactID

func (*Broadcast) CreateBatch added in v0.0.60

func (b *Broadcast) CreateBatch(contactIDs []flows.ContactID) *BroadcastBatch

func (*Broadcast) GroupIDs added in v0.0.60

func (b *Broadcast) GroupIDs() []GroupID

func (*Broadcast) MarshalJSON added in v0.0.60

func (b *Broadcast) MarshalJSON() ([]byte, error)

func (*Broadcast) OrgID added in v0.0.60

func (b *Broadcast) OrgID() OrgID

func (*Broadcast) Translations added in v0.0.60

func (b *Broadcast) Translations() map[utils.Language]*BroadcastTranslation

func (*Broadcast) URNs added in v0.0.60

func (b *Broadcast) URNs() []urns.URN

func (*Broadcast) UnmarshalJSON added in v0.0.60

func (b *Broadcast) UnmarshalJSON(data []byte) error

type BroadcastBatch added in v0.0.60

type BroadcastBatch struct {
	// contains filtered or unexported fields
}

BroadcastBatch represents a batch of contacts that need messages sent for

func (*BroadcastBatch) BaseLanguage added in v0.0.60

func (b *BroadcastBatch) BaseLanguage() utils.Language

func (*BroadcastBatch) ContactIDs added in v0.0.60

func (b *BroadcastBatch) ContactIDs() []flows.ContactID

func (*BroadcastBatch) IsLast added in v0.0.60

func (b *BroadcastBatch) IsLast() bool

func (*BroadcastBatch) MarshalJSON added in v0.0.60

func (b *BroadcastBatch) MarshalJSON() ([]byte, error)

func (*BroadcastBatch) OrgID added in v0.0.60

func (b *BroadcastBatch) OrgID() OrgID

func (*BroadcastBatch) SetIsLast added in v0.0.60

func (b *BroadcastBatch) SetIsLast(last bool)

func (*BroadcastBatch) SetURNs added in v0.0.60

func (b *BroadcastBatch) SetURNs(urns map[flows.ContactID]urns.URN)

func (*BroadcastBatch) Translations added in v0.0.60

func (b *BroadcastBatch) Translations() map[utils.Language]*BroadcastTranslation

func (*BroadcastBatch) URNs added in v0.0.60

func (b *BroadcastBatch) URNs() map[flows.ContactID]urns.URN

func (*BroadcastBatch) UnmarshalJSON added in v0.0.60

func (b *BroadcastBatch) UnmarshalJSON(data []byte) error

type BroadcastID added in v0.0.60

type BroadcastID int64

type BroadcastTranslation added in v0.0.60

type BroadcastTranslation struct {
	Text         string             `json:"text"`
	Attachments  []flows.Attachment `json:"attachments,omitempty"`
	QuickReplies []string           `json:"quick_replies,omitempty"`
}

BroadcastTranslation is the translation for the passed in language

type Campaign added in v0.0.17

type Campaign struct {
	// contains filtered or unexported fields
}

Campaign is our struct for a campaign and all its events

func (*Campaign) Events added in v0.0.17

func (c *Campaign) Events() []*CampaignEvent

Events returns the list of events for this campaign

func (*Campaign) GroupID added in v0.0.17

func (c *Campaign) GroupID() GroupID

GroupID returns the id of the group this campaign works against

func (*Campaign) GroupUUID added in v0.0.17

func (c *Campaign) GroupUUID() assets.GroupUUID

GroupUUID returns the uuid of the group this campaign works against

func (*Campaign) ID added in v0.0.17

func (c *Campaign) ID() CampaignID

ID return the database id of this campaign

func (*Campaign) Name added in v0.0.17

func (c *Campaign) Name() string

Name returns the name of this campaign

func (*Campaign) UUID added in v0.0.17

func (c *Campaign) UUID() CampaignUUID

UUID returns the UUID of this campaign

type CampaignEvent added in v0.0.17

type CampaignEvent struct {
	// contains filtered or unexported fields
}

func (*CampaignEvent) Campaign added in v0.0.17

func (e *CampaignEvent) Campaign() *Campaign

Campaign returns the campaign this event is part of

func (*CampaignEvent) DeliveryHour added in v0.0.17

func (e *CampaignEvent) DeliveryHour() int

DeliveryHour returns the hour this event should send at, if any

func (*CampaignEvent) ID added in v0.0.17

ID returns the database id for this campaign event

func (*CampaignEvent) Offset added in v0.0.17

func (e *CampaignEvent) Offset() int

Offset returns the offset for thi campaign event

func (*CampaignEvent) QualifiesByField added in v0.0.50

func (e *CampaignEvent) QualifiesByField(contact *flows.Contact) bool

QualifiesByField returns whether the passed in contact qualifies for this event by group membership

func (*CampaignEvent) QualifiesByGroup added in v0.0.50

func (e *CampaignEvent) QualifiesByGroup(contact *flows.Contact) bool

QualifiesByGroup returns whether the passed in contact qualifies for this event by group membership

func (*CampaignEvent) RelativeToID added in v0.0.17

func (e *CampaignEvent) RelativeToID() FieldID

RelativeToID returns the ID of the field this event is relative to

func (*CampaignEvent) RelativeToKey added in v0.0.17

func (e *CampaignEvent) RelativeToKey() string

RelativeToKey returns the key of the field this event is relative to

func (*CampaignEvent) ScheduleForContact added in v0.0.38

func (e *CampaignEvent) ScheduleForContact(tz *time.Location, now time.Time, contact *flows.Contact) (*time.Time, error)

ScheduleForContact calculates the next fire ( if any) for the passed in contact

func (*CampaignEvent) ScheduleForTime added in v0.0.17

func (e *CampaignEvent) ScheduleForTime(tz *time.Location, now time.Time, start time.Time) (*time.Time, error)

ScheduleForTime calculates the next fire (if any) for the passed in time and timezone

func (*CampaignEvent) StartMode added in v0.0.42

func (e *CampaignEvent) StartMode() StartMode

StartMode returns the start mode for this campaign event

func (*CampaignEvent) UUID added in v0.0.17

func (e *CampaignEvent) UUID() CampaignEventUUID

UUID returns the UUID of this campaign event

func (*CampaignEvent) Unit added in v0.0.17

func (e *CampaignEvent) Unit() OffsetUnit

Unit returns the unit for this campaign event

func (*CampaignEvent) UnmarshalJSON added in v0.0.17

func (e *CampaignEvent) UnmarshalJSON(data []byte) error

UnmarshalJSON is our unmarshaller for json data

type CampaignEventID added in v0.0.17

type CampaignEventID int

CampaignEventID is our type for campaign event ids

type CampaignEventUUID added in v0.0.17

type CampaignEventUUID utils.UUID

CampaignEventUUID is our type for campaign event UUIDs

type CampaignID added in v0.0.17

type CampaignID int

CampaignID is our type for campaign ids

type CampaignUUID added in v0.0.17

type CampaignUUID utils.UUID

CampaignUUID is our type for campaign UUIDs

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) Address added in v0.0.5

func (c *Channel) Address() string

Address returns the name of this channel

func (*Channel) ChannelReference added in v0.0.38

func (c *Channel) ChannelReference() *assets.ChannelReference

ChannelReference return a channel reference for this channel

func (*Channel) Country added in v0.0.5

func (c *Channel) Country() string

Country returns the contry code for this channel

func (*Channel) ID added in v0.0.5

func (c *Channel) ID() ChannelID

ID returns the id of this channel

func (*Channel) MatchPrefixes added in v0.0.5

func (c *Channel) MatchPrefixes() []string

MatchPrefixes returns the prefixes we should also match when determining channel affinity

func (*Channel) Name added in v0.0.5

func (c *Channel) Name() string

Name returns the name of this channel

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) Schemes added in v0.0.5

func (c *Channel) Schemes() []string

Schemes returns the schemes this channel supports

func (*Channel) TPS added in v0.0.5

func (c *Channel) TPS() int

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 ChannelID

type ChannelID int

type ChannelType added in v0.0.5

type ChannelType string

type ConnectionID

type ConnectionID null.Int

type Contact added in v0.0.38

type Contact struct {
	// contains filtered or unexported fields
}

Contact is our mailroom struct that represents a contact

func LoadContacts added in v0.0.5

func LoadContacts(ctx context.Context, db Queryer, org *OrgAssets, ids []flows.ContactID) ([]*Contact, error)

LoadContacts loads a set of contacts for the passed in ids

func (*Contact) CreatedOn added in v0.0.38

func (c *Contact) CreatedOn() time.Time

func (*Contact) Fields added in v0.0.38

func (c *Contact) Fields() map[string]*flows.Value

func (*Contact) FlowContact added in v0.0.38

func (c *Contact) FlowContact(org *OrgAssets, session flows.SessionAssets) (*flows.Contact, error)

FlowContact converts our mailroom contact into a flow contact for use in the engine

func (*Contact) Groups added in v0.0.38

func (c *Contact) Groups() []assets.Group

func (*Contact) ID added in v0.0.38

func (c *Contact) ID() flows.ContactID

func (*Contact) IsBlocked added in v0.0.38

func (c *Contact) IsBlocked() bool

func (*Contact) IsStopped added in v0.0.38

func (c *Contact) IsStopped() bool

func (*Contact) Language added in v0.0.38

func (c *Contact) Language() utils.Language

func (*Contact) ModifiedOn added in v0.0.38

func (c *Contact) ModifiedOn() time.Time

func (*Contact) Name added in v0.0.38

func (c *Contact) Name() string

func (*Contact) URNs added in v0.0.38

func (c *Contact) URNs() []urns.URN

func (*Contact) UUID added in v0.0.38

func (c *Contact) UUID() flows.ContactUUID

func (*Contact) Unstop added in v0.0.38

func (c *Contact) Unstop(ctx context.Context, db *sqlx.DB) error

Unstop sets the is_stopped attribute to false for this contact

func (*Contact) UpdatePreferredURN added in v0.0.48

func (c *Contact) UpdatePreferredURN(ctx context.Context, tx Queryer, org *OrgAssets, urnID URNID, channel *Channel) error

UpdatePreferredURN updates the URNs for the contact (if needbe) to have the passed in URN as top priority with the passed in channel as the preferred channel

type ContactURNsChanged added in v0.0.48

type ContactURNsChanged struct {
	ContactID flows.ContactID
	OrgID     OrgID
	URNs      []urns.URN
}

ContactURNsChanged represents the new status of URNs for a contact

type EventCommitHook added in v0.0.19

type EventCommitHook interface {
	Apply(context.Context, *sqlx.Tx, *redis.Pool, *OrgAssets, map[*Session][]interface{}) error
}

EventCommitHook defines a callback that will accept a certain type of events across session, either before or after committing

type EventFire added in v0.0.19

type EventFire struct {
	FireID    FireID          `db:"fire_id"`
	EventID   CampaignEventID `db:"event_id"`
	ContactID flows.ContactID `db:"contact_id"`
	Scheduled time.Time       `db:"scheduled"`
	Fired     *time.Time      `db:"fired"`
}

EventFire represents a single campaign event fire for an event and contact

func LoadEventFires added in v0.0.19

func LoadEventFires(ctx context.Context, db *sqlx.DB, ids []int64) ([]*EventFire, error)

LoadEventFires loads all the event fires with the passed in ids

type EventHandler added in v0.0.17

type EventHandler func(context.Context, *sqlx.Tx, *redis.Pool, *OrgAssets, *Session, flows.Event) error

EventHandler defines a call for handling events that occur in a flow

type ExitType

type ExitType null.String

type Field added in v0.0.5

type Field struct {
	// contains filtered or unexported fields
}

Field is our mailroom type for contact field types

func (*Field) ID added in v0.0.17

func (f *Field) ID() FieldID

ID returns the ID of this field

func (*Field) Key added in v0.0.5

func (f *Field) Key() string

Key returns the key for this field

func (*Field) Name added in v0.0.5

func (f *Field) Name() string

Name returns the name for this field

func (*Field) Type added in v0.0.5

func (f *Field) Type() assets.FieldType

Type returns the value type for this field

func (*Field) UUID added in v0.0.5

func (f *Field) UUID() FieldUUID

UUID returns the UUID of this field

type FieldID added in v0.0.17

type FieldID int

FieldID is our type for the database field ID

type FieldUUID added in v0.0.5

type FieldUUID utils.UUID

FieldUUID is our type for the UUID of a field

type FireAdd added in v0.0.38

type FireAdd struct {
	ContactID flows.ContactID `db:"contact_id"`
	EventID   CampaignEventID `db:"event_id"`
	Scheduled time.Time       `db:"scheduled"`
}

type FireDelete added in v0.0.38

type FireDelete struct {
	ContactID flows.ContactID `db:"contact_id"`
	EventID   CampaignEventID `db:"event_id"`
}

type FireID added in v0.0.19

type FireID int

FireID is our id for our event fires

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

func (*Flow) FlowReference added in v0.0.38

func (f *Flow) FlowReference() *assets.FlowReference

FlowReference return a channel reference for this flow

func (*Flow) ID added in v0.0.5

func (f *Flow) ID() FlowID

ID returns the ID for this flow

func (*Flow) IgnoreTriggers added in v0.0.38

func (f *Flow) IgnoreTriggers() bool

IgnoreTriggers returns whether this flow ignores triggers

func (*Flow) IsArchived added in v0.0.27

func (f *Flow) IsArchived() bool

IsArchived returns whether this flow is archived

func (*Flow) Name added in v0.0.5

func (f *Flow) Name() string

Name returns the name of this flow

func (*Flow) SetDefinition added in v0.0.49

func (f *Flow) SetDefinition(definition json.RawMessage)

SetDefinition sets our definition from the passed in new definition format

func (*Flow) SetLegacyDefinition added in v0.0.49

func (f *Flow) SetLegacyDefinition(legacyDefinition json.RawMessage) error

SetLegacyDefinition sets our definition from the passed in legacy definition

func (*Flow) UUID added in v0.0.5

func (f *Flow) UUID() assets.FlowUUID

UUID returns the UUID for this flow

type FlowID

type FlowID int

type FlowRun

type FlowRun struct {
	ID         FlowRunID     `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"`
	ParentUUID      *flows.RunUUID  `db:"parent_uuid"`
	SessionID       SessionID       `db:"session_id"`
	StartID         StartID         `db:"start_id"`
	// contains filtered or unexported fields
}

FlowRun is the mailroom type for a FlowRun

type FlowRunID added in v0.0.38

type FlowRunID int64

type FlowStart added in v0.0.27

type FlowStart struct {
	// contains filtered or unexported fields
}

FlowStart represents the top level flow start in our system

func NewFlowStart added in v0.0.27

func NewFlowStart(
	startID StartID, orgID OrgID, flowID FlowID,
	groupIDs []GroupID, contactIDs []flows.ContactID, urns []urns.URN, createContact bool,
	restartParticipants bool, includeActive bool, parent json.RawMessage) *FlowStart

func (*FlowStart) ContactIDs added in v0.0.27

func (s *FlowStart) ContactIDs() []flows.ContactID

func (*FlowStart) CreateBatch added in v0.0.27

func (s *FlowStart) CreateBatch(contactIDs []flows.ContactID) *FlowStartBatch

func (*FlowStart) CreateContact added in v0.0.58

func (s *FlowStart) CreateContact() bool

func (*FlowStart) FlowID added in v0.0.27

func (s *FlowStart) FlowID() FlowID

func (*FlowStart) GroupIDs added in v0.0.27

func (s *FlowStart) GroupIDs() []GroupID

func (*FlowStart) IncludeActive added in v0.0.27

func (s *FlowStart) IncludeActive() bool

func (*FlowStart) MarshalJSON added in v0.0.27

func (s *FlowStart) MarshalJSON() ([]byte, error)

func (*FlowStart) OrgID added in v0.0.27

func (s *FlowStart) OrgID() OrgID

func (*FlowStart) Parent added in v0.0.58

func (s *FlowStart) Parent() json.RawMessage

func (*FlowStart) RestartParticipants added in v0.0.27

func (s *FlowStart) RestartParticipants() bool

func (*FlowStart) StartID added in v0.0.27

func (s *FlowStart) StartID() StartID

func (*FlowStart) URNs added in v0.0.58

func (s *FlowStart) URNs() []urns.URN

func (*FlowStart) UnmarshalJSON added in v0.0.27

func (s *FlowStart) UnmarshalJSON(data []byte) error

type FlowStartBatch added in v0.0.27

type FlowStartBatch struct {
	// contains filtered or unexported fields
}

FlowStartBatch represents a single flow batch that needs to be started

func (*FlowStartBatch) ContactIDs added in v0.0.27

func (b *FlowStartBatch) ContactIDs() []flows.ContactID

func (*FlowStartBatch) FlowID added in v0.0.27

func (b *FlowStartBatch) FlowID() FlowID

func (*FlowStartBatch) IncludeActive added in v0.0.27

func (b *FlowStartBatch) IncludeActive() bool

func (*FlowStartBatch) IsLast added in v0.0.27

func (b *FlowStartBatch) IsLast() bool

func (*FlowStartBatch) MarshalJSON added in v0.0.27

func (b *FlowStartBatch) MarshalJSON() ([]byte, error)

func (*FlowStartBatch) OrgID added in v0.0.27

func (b *FlowStartBatch) OrgID() OrgID

func (*FlowStartBatch) Parent added in v0.0.58

func (b *FlowStartBatch) Parent() json.RawMessage

func (*FlowStartBatch) RestartParticipants added in v0.0.27

func (b *FlowStartBatch) RestartParticipants() bool

func (*FlowStartBatch) SetIsLast added in v0.0.27

func (b *FlowStartBatch) SetIsLast(last bool)

func (*FlowStartBatch) StartID added in v0.0.27

func (b *FlowStartBatch) StartID() StartID

func (*FlowStartBatch) UnmarshalJSON added in v0.0.27

func (b *FlowStartBatch) UnmarshalJSON(data []byte) error

type Group added in v0.0.5

type Group struct {
	// contains filtered or unexported fields
}

Group is our mailroom type for contact groups

func (*Group) ID added in v0.0.5

func (g *Group) ID() GroupID

ID returns the ID for this group

func (*Group) Name added in v0.0.5

func (g *Group) Name() string

Name returns the name for this group

func (*Group) Query added in v0.0.5

func (g *Group) Query() string

Query returns the query string (if any) for this group

func (*Group) UUID added in v0.0.5

func (g *Group) UUID() assets.GroupUUID

UUID returns the uuid for this group

type GroupAdd added in v0.0.38

type GroupAdd struct {
	ContactID flows.ContactID `db:"contact_id"`
	GroupID   GroupID         `db:"group_id"`
}

GroupAdd is our struct to track a final group additions

type GroupID added in v0.0.5

type GroupID int

type GroupRemove added in v0.0.38

type GroupRemove struct {
	ContactID flows.ContactID `db:"contact_id"`
	GroupID   GroupID         `db:"group_id"`
}

GroupRemove is our struct to track group removals

type Label added in v0.0.5

type Label struct {
	// contains filtered or unexported fields
}

Label is our mailroom type for message labels

func (*Label) ID added in v0.0.5

func (l *Label) ID() LabelID

ID returns the ID for this label

func (*Label) Name added in v0.0.5

func (l *Label) Name() string

Name returns the name for this label

func (*Label) UUID added in v0.0.5

func (l *Label) UUID() assets.LabelUUID

UUID returns the uuid for this label

type LabelID added in v0.0.5

type LabelID int

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

func (*Location) Aliases added in v0.0.5

func (l *Location) Aliases() []string

Aliases returns the list of aliases for this location

func (*Location) Children added in v0.0.5

func (l *Location) Children() []*Location

Children returns the list of children for this location

func (*Location) ID added in v0.0.5

func (l *Location) ID() int

ID returns the database id for this location

func (*Location) Level added in v0.0.5

func (l *Location) Level() int

Level returns the level for this location

func (*Location) Name added in v0.0.5

func (l *Location) Name() string

Name returns the name for this location

func (*Location) OSMID added in v0.0.5

func (l *Location) OSMID() string

OSMID returns the OSM ID for this location

type MatchType added in v0.0.38

type MatchType string

type Msg

type Msg struct {
	// contains filtered or unexported fields
}

Msg is our type for mailroom messages

func CreateBroadcastMessages added in v0.0.60

func CreateBroadcastMessages(ctx context.Context, db *sqlx.DB, org *OrgAssets, sa flows.SessionAssets, bcast *BroadcastBatch) ([]*Msg, error)

func NewOutgoingMsg added in v0.0.17

func NewOutgoingMsg(orgID OrgID, channel *Channel, contactID flows.ContactID, out *flows.MsgOut, createdOn time.Time) (*Msg, error)

NewOutgoingMsg creates an outgoing message for the passed in flow message. Note that this message is created in a queued state!

func (*Msg) Attachments

func (m *Msg) Attachments() []flows.Attachment

func (*Msg) Channel added in v0.0.5

func (m *Msg) Channel() *Channel

func (*Msg) ChannelID

func (m *Msg) ChannelID() ChannelID

func (*Msg) ChannelUUID

func (m *Msg) ChannelUUID() assets.ChannelUUID

func (*Msg) ConnectionID

func (m *Msg) ConnectionID() ConnectionID

func (*Msg) ContactID

func (m *Msg) ContactID() flows.ContactID

func (*Msg) ContactURNID

func (m *Msg) ContactURNID() URNID

func (*Msg) CreatedOn

func (m *Msg) CreatedOn() time.Time

func (*Msg) Direction

func (m *Msg) Direction() MsgDirection

func (*Msg) ErrorCount

func (m *Msg) ErrorCount() int

func (*Msg) ExternalID

func (m *Msg) ExternalID() null.String

func (*Msg) HighPriority

func (m *Msg) HighPriority() bool

func (*Msg) ID

func (m *Msg) ID() flows.MsgID

func (*Msg) MarshalJSON added in v0.0.38

func (m *Msg) MarshalJSON() ([]byte, error)

func (*Msg) Metadata

func (m *Msg) Metadata() types.JSONText

func (*Msg) ModifiedOn

func (m *Msg) ModifiedOn() time.Time

func (*Msg) MsgCount

func (m *Msg) MsgCount() int

func (*Msg) MsgType

func (m *Msg) MsgType() MsgType

func (*Msg) NextAttempt

func (m *Msg) NextAttempt() time.Time

func (*Msg) OrgID

func (m *Msg) OrgID() OrgID

func (*Msg) QueuedOn

func (m *Msg) QueuedOn() time.Time

func (*Msg) SentOn

func (m *Msg) SentOn() time.Time

func (*Msg) SetResponseTo added in v0.0.53

func (m *Msg) SetResponseTo(id null.Int, externalID string)

SetResponseTo set the incoming message that this session should be associated with in this sprint

func (*Msg) SetTimeout added in v0.0.68

func (m *Msg) SetTimeout(id SessionID, start time.Time, timeout time.Duration)

SetTimeout sets the timeout for this message

func (*Msg) SetTopup added in v0.0.38

func (m *Msg) SetTopup(topupID TopupID)

func (*Msg) Status

func (m *Msg) Status() MsgStatus

func (*Msg) Text

func (m *Msg) Text() string

func (*Msg) TopupID added in v0.0.38

func (m *Msg) TopupID() TopupID

func (*Msg) URN

func (m *Msg) URN() urns.URN

func (*Msg) URNAuth added in v0.0.5

func (m *Msg) URNAuth() string

func (*Msg) UUID

func (m *Msg) UUID() flows.MsgUUID

func (*Msg) Visibility

func (m *Msg) Visibility() MsgVisibility

type MsgDirection

type MsgDirection string

type MsgLabelAdd added in v0.0.53

type MsgLabelAdd struct {
	MsgID   flows.MsgID `db:"msg_id"`
	LabelID LabelID     `db:"label_id"`
}

MsgLabelAdd represents a single label that should be added to a message

type MsgStatus

type MsgStatus string

type MsgType

type MsgType string

type MsgVisibility

type MsgVisibility string

type OffsetUnit added in v0.0.17

type OffsetUnit string

OffsetUnit defines what time unit our offset is in

type Org added in v0.0.5

type Org struct {
	// contains filtered or unexported fields
}

Org is mailroom's type for RapidPro orgs. It also implements the utils.Environment interface for GoFlow

func (*Org) AllowedLanguages added in v0.0.38

func (o *Org) AllowedLanguages() []utils.Language

AllowedLanguages returns the list of supported languages for this org

func (*Org) ConfigValue added in v0.0.44

func (o *Org) ConfigValue(key string, def string) string

ConfigValue returns the string value for the passed in config (or default if not found)

func (*Org) DateFormat added in v0.0.5

func (o *Org) DateFormat() utils.DateFormat

DateFormat returns the date format for this org

func (*Org) DefaultCountry added in v0.0.49

func (o *Org) DefaultCountry() utils.Country

DefaultCountry returns the default country for this organization (mostly used for number parsing)

func (*Org) DefaultLanguage added in v0.0.38

func (o *Org) DefaultLanguage() utils.Language

DefaultLanguage returns the primary language for this org

func (*Org) Equal added in v0.0.38

func (o *Org) Equal(env utils.Environment) bool

Equal return whether we are equal to the passed in environment

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) ID added in v0.0.5

func (o *Org) ID() OrgID

ID returns the id of the org

func (*Org) MarshalJSON added in v0.0.22

func (o *Org) MarshalJSON() ([]byte, error)

MarshalJSON is our custom marshaller so that our inner env get output

func (*Org) Now added in v0.0.5

func (o *Org) Now() time.Time

Now returns the current time in the current timezone for this org

func (*Org) NumberFormat added in v0.0.38

func (o *Org) NumberFormat() *utils.NumberFormat

NumberFormat returns the date format 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

func (*Org) Timezone added in v0.0.5

func (o *Org) Timezone() *time.Location

Timezone returns the timezone for this org

type OrgAssets

type OrgAssets struct {
	// contains filtered or unexported fields
}

OrgAssets is our top level cache of all things contained in an org. It is used to build SessionAssets for the engine but also used to cache campaigns and other org level attributes

func GetOrgAssets added in v0.0.5

func GetOrgAssets(ctx context.Context, db *sqlx.DB, orgID OrgID) (*OrgAssets, error)

GetOrgAssets creates or gets org assets for the passed in org

func NewOrgAssets

func NewOrgAssets(ctx context.Context, db *sqlx.DB, orgID OrgID, prev *OrgAssets) (*OrgAssets, error)

NewOrgAssets creates and returns a new org assets objects, potentially using the previous org assets passed in to prevent refetching locations

func (*OrgAssets) CampaignByGroupID added in v0.0.17

func (a *OrgAssets) CampaignByGroupID(groupID GroupID) []*Campaign

func (*OrgAssets) CampaignEventByID added in v0.0.27

func (a *OrgAssets) CampaignEventByID(eventID CampaignEventID) *CampaignEvent

func (*OrgAssets) CampaignEventsByFieldID added in v0.0.17

func (a *OrgAssets) CampaignEventsByFieldID(fieldID FieldID) []*CampaignEvent

func (*OrgAssets) Campaigns added in v0.0.17

func (a *OrgAssets) Campaigns() []*Campaign

func (*OrgAssets) ChannelByID added in v0.0.5

func (a *OrgAssets) ChannelByID(channelID ChannelID) *Channel

func (*OrgAssets) ChannelByUUID added in v0.0.5

func (a *OrgAssets) ChannelByUUID(channelUUID assets.ChannelUUID) *Channel

func (*OrgAssets) Channels added in v0.0.5

func (a *OrgAssets) Channels() ([]assets.Channel, error)

func (*OrgAssets) Env added in v0.0.5

func (a *OrgAssets) Env() utils.Environment

func (*OrgAssets) FieldByKey added in v0.0.17

func (a *OrgAssets) FieldByKey(key string) *Field

func (*OrgAssets) FieldByUUID added in v0.0.5

func (a *OrgAssets) FieldByUUID(fieldUUID FieldUUID) *Field

func (*OrgAssets) Fields added in v0.0.5

func (a *OrgAssets) Fields() ([]assets.Field, error)

func (*OrgAssets) Flow added in v0.0.5

func (a *OrgAssets) Flow(flowUUID assets.FlowUUID) (assets.Flow, error)

func (*OrgAssets) FlowByID added in v0.0.27

func (a *OrgAssets) FlowByID(flowID FlowID) (*Flow, error)

func (*OrgAssets) GroupByID added in v0.0.5

func (a *OrgAssets) GroupByID(groupID GroupID) *Group

func (*OrgAssets) GroupByUUID added in v0.0.5

func (a *OrgAssets) GroupByUUID(groupUUID assets.GroupUUID) *Group

func (*OrgAssets) Groups added in v0.0.5

func (a *OrgAssets) Groups() ([]assets.Group, error)

func (*OrgAssets) LabelByUUID added in v0.0.53

func (a *OrgAssets) LabelByUUID(uuid assets.LabelUUID) *Label

func (*OrgAssets) Labels added in v0.0.5

func (a *OrgAssets) Labels() ([]assets.Label, error)

func (*OrgAssets) Locations added in v0.0.5

func (a *OrgAssets) Locations() ([]assets.LocationHierarchy, error)

func (*OrgAssets) Org added in v0.0.44

func (a *OrgAssets) Org() *Org

func (*OrgAssets) OrgID added in v0.0.5

func (a *OrgAssets) OrgID() OrgID

func (*OrgAssets) Resthooks added in v0.0.5

func (a *OrgAssets) Resthooks() ([]assets.Resthook, error)

func (*OrgAssets) SetFlow added in v0.0.38

func (a *OrgAssets) SetFlow(flowID FlowID, flow flows.Flow) (*Flow, error)

SetFlow sets the flow definition for the passed in ID. Should only be used for unit tests

func (*OrgAssets) Triggers added in v0.0.38

func (a *OrgAssets) Triggers() []*Trigger

type OrgID

type OrgID int

type Queryer added in v0.0.38

type Queryer interface {
	Rebind(query string) string
	QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
}

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) Slug added in v0.0.5

func (r *Resthook) Slug() string

Slug returns the slug for this resthook

func (*Resthook) Subscribers added in v0.0.5

func (r *Resthook) Subscribers() []string

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 ResthookUnsubscribe added in v0.0.38

type ResthookUnsubscribe struct {
	OrgID OrgID  `db:"org_id"`
	Slug  string `db:"slug"`
	URL   string `db:"url"`
}

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       `db:"created_on"`
	EndedOn       *time.Time      `db:"ended_on"`
	TimeoutOn     *time.Time      `db:"timeout_on"`
	WaitStartedOn *time.Time      `db:"wait_started_on"`
	CurrentFlowID *FlowID         `db:"current_flow_id"`

	IncomingMsgID      null.Int
	IncomingExternalID string
	// contains filtered or unexported fields
}

Session is the mailroom type for a FlowSession

func ActiveSessionForContact added in v0.0.38

func ActiveSessionForContact(ctx context.Context, db *sqlx.DB, org *OrgAssets, contact *flows.Contact) (*Session, error)

ActiveSessionForContact returns the active session for the passed in contact, if any

func NewSession added in v0.0.17

func NewSession(org *OrgAssets, s flows.Session) (*Session, error)

NewSession a session objects from the passed in flow session. It does NOT commit said session to the database.

func WriteSessions added in v0.0.10

func WriteSessions(ctx context.Context, tx *sqlx.Tx, rp *redis.Pool, org *OrgAssets, ss []flows.Session, es [][]flows.Event, hook SessionCommitHook) ([]*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) AddPostCommitEvent added in v0.0.17

func (s *Session) AddPostCommitEvent(hook EventCommitHook, event interface{})

AddPostCommitEvent adds a new event to be handled by a post commit hook

func (*Session) AddPreCommitEvent added in v0.0.17

func (s *Session) AddPreCommitEvent(hook EventCommitHook, event interface{})

AddPreCommitEvent adds a new event to be handled by a pre commit hook

func (*Session) Contact added in v0.0.17

func (s *Session) Contact() *flows.Contact

Contact returns the contact for this session

func (*Session) ContactUUID added in v0.0.17

func (s *Session) ContactUUID() flows.ContactUUID

ContactUUID returns the UUID of our contact

func (*Session) FlowSession added in v0.0.38

func (s *Session) FlowSession(sa flows.SessionAssets, env utils.Environment, client *utils.HTTPClient) (flows.Session, error)

FlowSession creates a flow session for the passed in session object. It also populates the runs we know about

func (*Session) OutputMD5 added in v0.0.68

func (s *Session) OutputMD5() string

OutputMD5 returns the md5 of the passed in session

func (*Session) Runs added in v0.0.17

func (s *Session) Runs() []*FlowRun

Runs returns our flow run

func (*Session) SetIncomingMsg added in v0.0.38

func (s *Session) SetIncomingMsg(id flows.MsgID, externalID string)

SetIncomingMsg set the incoming message that this session should be associated with in this sprint

func (*Session) Timeout added in v0.0.68

func (s *Session) Timeout() *time.Duration

Timeout returns the amount of time after our last message sends that we should timeout

func (*Session) WriteUpdatedSession added in v0.0.38

func (s *Session) WriteUpdatedSession(ctx context.Context, tx *sqlx.Tx, rp *redis.Pool, org *OrgAssets, fs flows.Session, es []flows.Event) error

WriteUpdatedSession updates the session based on the state passed in from our engine session, this also takes care of applying any event hooks

type SessionCommitHook added in v0.0.19

type SessionCommitHook func(context.Context, *sqlx.Tx, *redis.Pool, *OrgAssets, []*Session) error

type SessionID

type SessionID int64

type SessionStatus

type SessionStatus string

type StartID added in v0.0.27

type StartID struct {
	null.Int
}

StartID is our type for flow start ids

func NewStartID added in v0.0.27

func NewStartID(id int) StartID

NewStartID creates a new start id for the passed in int

type StartMode added in v0.0.42

type StartMode string

StartMode defines how a campaign event should be started

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

type TopupID added in v0.0.10

type TopupID null.Int

TopupID is our type for topup ids, which can be null

func DecrementOrgCredits added in v0.0.17

func DecrementOrgCredits(ctx context.Context, db sqlx.Queryer, rc redis.Conn, orgID OrgID, amount int) (TopupID, error)

type Trigger added in v0.0.38

type Trigger struct {
	// contains filtered or unexported fields
}

Trigger represents a trigger in an organization

func FindMatchingMsgTrigger added in v0.0.38

func FindMatchingMsgTrigger(org *OrgAssets, contact *flows.Contact, text string) *Trigger

FindMatchingMsgTrigger returns the matching trigger (if any) for the passed in text and channel id TODO: with a different structure this could probably be a lot faster.. IE, we could have a map of list of triggers by keyword that is built when we load the triggers, then just evaluate against that.

func FindMatchingNewConversationTrigger added in v0.0.38

func FindMatchingNewConversationTrigger(org *OrgAssets, channel *Channel) *Trigger

FindMatchingNewConversationTrigger returns the matching trigger for the passed in trigger type

func FindMatchingReferralTrigger added in v0.0.38

func FindMatchingReferralTrigger(org *OrgAssets, channel *Channel, referrerID string) *Trigger

FindMatchingReferralTrigger returns the matching trigger for the passed in trigger type Matches are based on referrer_id first (if present), then channel, then any referrer trigger

func (*Trigger) ChannelID added in v0.0.38

func (t *Trigger) ChannelID() ChannelID

func (*Trigger) FlowID added in v0.0.38

func (t *Trigger) FlowID() FlowID

func (*Trigger) GroupIDs added in v0.0.38

func (t *Trigger) GroupIDs() []GroupID

func (*Trigger) ID added in v0.0.38

func (t *Trigger) ID() TriggerID

func (*Trigger) Keyword added in v0.0.38

func (t *Trigger) Keyword() string

func (*Trigger) KeywordMatchType added in v0.0.38

func (t *Trigger) KeywordMatchType() triggers.KeywordMatchType

func (*Trigger) MatchType added in v0.0.38

func (t *Trigger) MatchType() MatchType

func (*Trigger) ReferrerID added in v0.0.38

func (t *Trigger) ReferrerID() string

func (*Trigger) TriggerType added in v0.0.38

func (t *Trigger) TriggerType() TriggerType

type TriggerID added in v0.0.38

type TriggerID int

type TriggerType added in v0.0.38

type TriggerType string

type URNID added in v0.0.38

type URNID int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL