db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2015 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package db manages the queuing/persistance for the postmaster

Index

Constants

View Source
const (
	DB         = "postmaster"
	EmailsColl = "emails"
	// stats is a reserved collection in mongo
	StatsColl = "records"
)

Names of databases and collections in mongo

View Source
const (
	Sent int = 1 << iota
	Delivered
	SpamReported
	Bounced
	Dropped
	Opened
)

Variables

View Source
var (
	UniqueArgID = "stats_id"
)

Functions

func GenerateEmailID

func GenerateEmailID(recipient string, flags int64) string

func MarkAsBounced

func MarkAsBounced(id string, reason string)

func MarkAsDelivered

func MarkAsDelivered(id string)

func MarkAsDropped

func MarkAsDropped(id string, reason string)

func MarkAsOpened

func MarkAsOpened(id string)

func MarkAsSpamReported

func MarkAsSpamReported(id string)

func RandomizeColls

func RandomizeColls()

this is ONLY exported so webhook_test can use it todo: we should find a way around exporting this

func StoreEmailBounce

func StoreEmailBounce(email string) error

func StoreEmailFlags

func StoreEmailFlags(email string, flags int64) error

func StoreEmailSpam

func StoreEmailSpam(email string) error

func StoreSendJob

func StoreSendJob(jobContents string) error

func StoreStatsJob

func StoreStatsJob(jobContents string) error

func VerifyEmailAllowed

func VerifyEmailAllowed(email string, flags int64) bool

Types

type EmailDoc

type EmailDoc struct {
	Email       string      `bson:"_id"`
	UnsubFlags  int64       `bson:"f"`
	Bounces     []time.Time `bson:"b"` //also includes *some* drops
	SpamReports []time.Time `bson:"s"`
	TSUpdated   time.Time   `bson:"ts"`
}

type StatDoc

type StatDoc struct {
	ID         bson.ObjectId `bson:"_id,omitempty"`
	Recipient  string        `bson:"r"`
	EmailFlags int64         `bson:"ef"`
	StateFlags int64         `bson:"s"`
	TSCreated  time.Time     `bson:"tc"`
	TSUpdated  time.Time     `bson:"ts"`
	Error      string        `bson:"err,omitempty"`
}

func GetStats

func GetStats(id string) *StatDoc

this is mostly for testing purposes

type StatsJob

type StatsJob struct {
	Email     string `json:"email" validate:"email,nonzero"` //Email address of the intended recipient
	Timestamp int64  `json:"timestamp,omitempty"`
	Type      string `json:"event" validate:"nonzero"`    //One of: bounce, deferred, delivered, dropped, processed
	StatsID   string `json:"stats_id" validate:"nonzero"` //json key must match db.UniqueArgID
	Reason    string `json:"reason,omitempty" validate:"max=1024"`
}

Jump to

Keyboard shortcuts

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