postal

package
v0.0.0-...-2dc3ea6 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2014 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmailFieldName      = "email"
	RecipientsFieldName = "recipient"
	EmptyIDForNonUser   = ""
)
View Source
const (
	StatusUnavailable = "unavailable"
	StatusFailed      = "failed"
	StatusDelivered   = "delivered"
	StatusNotFound    = "notfound"
	StatusNoAddress   = "noaddress"
	StatusQueued      = "queued"
)
View Source
const (
	SubjectMissingTemplateName  = "subject.missing"
	SubjectProvidedTemplateName = "subject.provided"
)
View Source
const (
	UserContentSuffix         = "user_body"
	OrganizationContentSuffix = "organization_body"
	SpaceContentSuffix        = "space_body"
	SubjectProvidedSuffix     = "subject.provided"
	SubjectMissingSuffix      = "subject.missing"
)

Variables

This section is empty.

Functions

func CCErrorFor

func CCErrorFor(err error) error

func ResetLoader

func ResetLoader()

func UAAErrorFor

func UAAErrorFor(err error) error

Types

type CCDownError

type CCDownError string

func (CCDownError) Error

func (err CCDownError) Error() string

type CCNotFoundError

type CCNotFoundError string

func (CCNotFoundError) Error

func (err CCNotFoundError) Error() string

type CriticalNotificationError

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

func NewCriticalNotificationError

func NewCriticalNotificationError(kindID string) CriticalNotificationError

func (CriticalNotificationError) Error

func (err CriticalNotificationError) Error() string

type Delivery

type Delivery struct {
	User         uaa.User
	Options      Options
	UserGUID     string
	Space        cf.CloudControllerSpace
	Organization cf.CloudControllerOrganization
	ClientID     string
	Templates    Templates
	MessageID    string
}

type DeliveryWorker

type DeliveryWorker struct {
	gobble.Worker
	// contains filtered or unexported fields
}

func NewDeliveryWorker

func NewDeliveryWorker(id int, logger *log.Logger, mailClient mail.ClientInterface, queue gobble.QueueInterface,
	globalUnsubscribesRepo models.GlobalUnsubscribesRepoInterface, unsubscribesRepo models.UnsubscribesRepoInterface,
	kindsRepo models.KindsRepoInterface, database models.DatabaseInterface, sender, encryptionKey string) DeliveryWorker

func (DeliveryWorker) Deliver

func (worker DeliveryWorker) Deliver(job *gobble.Job)

func (DeliveryWorker) Retry

func (worker DeliveryWorker) Retry(job *gobble.Job)

func (DeliveryWorker) SendMail

func (worker DeliveryWorker) SendMail(message mail.Message) string

func (DeliveryWorker) ShouldDeliver

func (worker DeliveryWorker) ShouldDeliver(delivery Delivery) bool

type EmailID

type EmailID string

func NewEmailID

func NewEmailID() EmailID

func (EmailID) BelongsToOrganization

func (guid EmailID) BelongsToOrganization() bool

func (EmailID) BelongsToSpace

func (guid EmailID) BelongsToSpace() bool

func (EmailID) IsTypeEmail

func (guid EmailID) IsTypeEmail() bool

func (EmailID) String

func (guid EmailID) String() string

type EmailRecipe

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

func NewEmailRecipe

func NewEmailRecipe(mailer MailerInterface, templatesLoader TemplatesLoaderInterface) EmailRecipe

func (EmailRecipe) Dispatch

func (recipe EmailRecipe) Dispatch(clientID string, guid TypedGUID,
	options Options, conn models.ConnectionInterface) ([]Response, error)

func (EmailRecipe) Trim

func (recipe EmailRecipe) Trim(responses []byte) []byte

type FileSystem

type FileSystem struct{}

func NewFileSystem

func NewFileSystem() *FileSystem

func (FileSystem) Exists

func (fs FileSystem) Exists(path string) bool

func (FileSystem) Read

func (fs FileSystem) Read(path string) (string, error)

type FileSystemInterface

type FileSystemInterface interface {
	Exists(string) bool
	Read(string) (string, error)
}

type GUIDGenerationFunc

type GUIDGenerationFunc func() (*uuid.UUID, error)

type HTML

type HTML struct {
	BodyContent    string
	BodyAttributes string
	Head           string
	Doctype        string
}

type Mailer

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

func NewMailer

func NewMailer(queue gobble.QueueInterface, guidGenerator GUIDGenerationFunc) Mailer

func (Mailer) Deliver

func (mailer Mailer) Deliver(conn models.ConnectionInterface, templates Templates, users map[string]uaa.User,
	options Options, space cf.CloudControllerSpace, organization cf.CloudControllerOrganization, clientID string) []Response

type MessageContext

type MessageContext struct {
	From              string
	ReplyTo           string
	To                string
	Subject           string
	Text              string
	HTML              string
	HTMLComponents    HTML
	TextTemplate      string
	HTMLTemplate      string
	SubjectTemplate   string
	KindDescription   string
	SourceDescription string
	UserGUID          string
	ClientID          string
	MessageID         string
	Space             string
	SpaceGUID         string
	Organization      string
	OrganizationGUID  string
	UnsubscribeID     string
}

func NewMessageContext

func NewMessageContext(delivery Delivery, sender string, cloak conceal.CloakInterface) MessageContext

func (*MessageContext) Escape

func (context *MessageContext) Escape()

type Options

type Options struct {
	ReplyTo           string
	Subject           string
	KindDescription   string
	SourceDescription string
	Text              string
	HTML              HTML
	KindID            string
	To                string
}

type OrganizationGUID

type OrganizationGUID string

func NewOrganizationGUID

func NewOrganizationGUID() OrganizationGUID

func (OrganizationGUID) BelongsToOrganization

func (guid OrganizationGUID) BelongsToOrganization() bool

func (OrganizationGUID) BelongsToSpace

func (guid OrganizationGUID) BelongsToSpace() bool

func (OrganizationGUID) IsTypeEmail

func (guid OrganizationGUID) IsTypeEmail() bool

func (OrganizationGUID) String

func (guid OrganizationGUID) String() string

type OrganizationRecipe

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

func NewOrganizationRecipe

func NewOrganizationRecipe(tokenLoader TokenLoaderInterface, userLoader UserLoaderInterface, spaceAndOrgLoader SpaceAndOrgLoaderInterface,
	templatesLoader TemplatesLoaderInterface, mailer MailerInterface, receiptsRepo models.ReceiptsRepoInterface) OrganizationRecipe

func (OrganizationRecipe) Dispatch

func (recipe OrganizationRecipe) Dispatch(clientID string, guid TypedGUID, options Options, conn models.ConnectionInterface) ([]Response, error)

func (OrganizationRecipe) Trim

func (recipe OrganizationRecipe) Trim(responses []byte) []byte

type Packager

type Packager struct{}

func NewPackager

func NewPackager() Packager

func (Packager) CompileBody

func (packager Packager) CompileBody(context MessageContext) (string, error)

func (Packager) Pack

func (packager Packager) Pack(context MessageContext) (mail.Message, error)

type RecipeInterface

type RecipeInterface interface {
	Dispatch(clientID string, guid TypedGUID, options Options, conn models.ConnectionInterface) ([]Response, error)
	Trim([]byte) []byte
}

type Response

type Response struct {
	Status         string `json:"status"`
	Recipient      string `json:"recipient"`
	NotificationID string `json:"notification_id"`
	Email          string `json:"email"`
}

type SpaceAndOrgLoader

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

func NewSpaceAndOrgLoader

func NewSpaceAndOrgLoader(cloudController cf.CloudControllerInterface) SpaceAndOrgLoader

func (SpaceAndOrgLoader) Error

func (SpaceAndOrgLoader) Load

type SpaceAndOrgLoaderInterface

type SpaceAndOrgLoaderInterface interface {
	Load(TypedGUID, string) (cf.CloudControllerSpace, cf.CloudControllerOrganization, error)
}

type SpaceGUID

type SpaceGUID string

func (SpaceGUID) BelongsToOrganization

func (guid SpaceGUID) BelongsToOrganization() bool

func (SpaceGUID) BelongsToSpace

func (guid SpaceGUID) BelongsToSpace() bool

func (SpaceGUID) IsTypeEmail

func (guid SpaceGUID) IsTypeEmail() bool

func (SpaceGUID) String

func (guid SpaceGUID) String() string

type SpaceRecipe

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

func NewSpaceRecipe

func NewSpaceRecipe(tokenLoader TokenLoaderInterface, userLoader UserLoaderInterface, spaceAndOrgLoader SpaceAndOrgLoaderInterface,
	templatesLoader TemplatesLoaderInterface, mailer MailerInterface, receiptsRepo models.ReceiptsRepoInterface) SpaceRecipe

func (SpaceRecipe) Dispatch

func (recipe SpaceRecipe) Dispatch(clientID string, guid TypedGUID, options Options, conn models.ConnectionInterface) ([]Response, error)

func (SpaceRecipe) Trim

func (recipe SpaceRecipe) Trim(responses []byte) []byte

type TemplateLoadError

type TemplateLoadError string

func (TemplateLoadError) Error

func (err TemplateLoadError) Error() string

type Templates

type Templates struct {
	Subject string
	Text    string
	HTML    string
}

type TemplatesLoader

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

func (TemplatesLoader) LoadTemplates

func (loader TemplatesLoader) LoadTemplates(subjectSuffix, contentSuffix, client, kind string) (Templates, error)

type TemplatesLoaderInterface

type TemplatesLoaderInterface interface {
	LoadTemplates(string, string, string, string) (Templates, error)
}

type TokenLoader

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

func NewTokenLoader

func NewTokenLoader(uaaClient UAAInterface) TokenLoader

func (TokenLoader) Load

func (loader TokenLoader) Load() (string, error)

type TokenLoaderInterface

type TokenLoaderInterface interface {
	Load() (string, error)
}

type Trimmer

type Trimmer struct{}

func (Trimmer) TrimFields

func (t Trimmer) TrimFields(responses []byte, field string) []byte

type TypedGUID

type TypedGUID interface {
	BelongsToSpace() bool
	BelongsToOrganization() bool
	IsTypeEmail() bool
	String() string
}

type UAA

type UAA string

type UAADownError

type UAADownError string

func (UAADownError) Error

func (err UAADownError) Error() string

type UAAGenericError

type UAAGenericError string

func (UAAGenericError) Error

func (err UAAGenericError) Error() string

type UAAScopesError

type UAAScopesError string

func (UAAScopesError) Error

func (err UAAScopesError) Error() string

type UAAUserNotFoundError

type UAAUserNotFoundError string

func (UAAUserNotFoundError) Error

func (err UAAUserNotFoundError) Error() string

type UserGUID

type UserGUID string

func NewUserGUID

func NewUserGUID() UserGUID

func (UserGUID) BelongsToOrganization

func (guid UserGUID) BelongsToOrganization() bool

func (UserGUID) BelongsToSpace

func (guid UserGUID) BelongsToSpace() bool

func (UserGUID) IsTypeEmail

func (guid UserGUID) IsTypeEmail() bool

func (UserGUID) String

func (guid UserGUID) String() string

type UserLoader

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

func NewUserLoader

func NewUserLoader(uaaClient UAAInterface, logger *log.Logger, cloudController cf.CloudControllerInterface) UserLoader

func (UserLoader) Load

func (loader UserLoader) Load(guid TypedGUID, token string) (map[string]uaa.User, error)

type UserLoaderInterface

type UserLoaderInterface interface {
	Load(TypedGUID, string) (map[string]uaa.User, error)
}

type UserRecipe

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

func NewUserRecipe

func NewUserRecipe(tokenLoader TokenLoaderInterface, userLoader UserLoaderInterface,
	templatesLoader TemplatesLoaderInterface, mailer MailerInterface, receiptsRepo models.ReceiptsRepoInterface) UserRecipe

func (UserRecipe) Dispatch

func (recipe UserRecipe) Dispatch(clientID string, guid TypedGUID, options Options, conn models.ConnectionInterface) ([]Response, error)

func (UserRecipe) Trim

func (recipe UserRecipe) Trim(responses []byte) []byte

Jump to

Keyboard shortcuts

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