Documentation
¶
Index ¶
Constants ¶
View Source
const ( ErrInvalid = "invalid" ErrForbidden = "forbidden" ErrNotFound = "not_found" ErrConflict = "conflict" ErrInternal = "internal" )
View Source
const ( StatusPendingConfirmation = "pending_confirmation" StatusActive = "active" StatusUnsubscribed = "unsubscribed" )
Subscribe status
Variables ¶
This section is empty.
Functions ¶
func ErrorMessage ¶
Types ¶
type Config ¶
type Config struct {
DB struct {
Type string // "bolt", "sqlite", etc.
Path string
}
HTTP struct {
Addr string
}
SMTP struct {
Host string
Port int
Username string
Password string
}
Newsletter struct {
From string
Frequency int
Cron struct {
Spec string
}
Product struct {
Name string
}
HMAC struct {
Secret string
}
}
Sentry struct {
DSN string
}
AMQP struct {
URL string
}
}
Config represents the main config
type EmailNewsletterRequest ¶
type NewsletterService ¶
type NewsletterService interface {
SendConfirmationEmail(to, url, token string) error
SendThankYouEmail(to string) error
SendNewsletter(subscribers []Subscriber, subject, body string)
GenerateNewUUID() string
GetHMACSecret() string
}
NewsletterService is the interface that wraps methods related to SMTP
type QueueService ¶
type Subscriber ¶
type Subscriber struct {
ID int `storm:"id,increment"`
Email string `storm:"unique"`
Status string `storm:"index"`
SubscribedAt time.Time
}
Subscriber represents a subscriber
type Subscription ¶
func NewSubscription ¶
func NewSubscription(email, status, token string) *Subscription
NewSubscription returns new subscriber
type SubscriptionRequest ¶
type SubscriptionService ¶
type SubscriptionService interface {
FindByEmail(email string) (*Subscriber, error)
Insert(s *Subscription) error
Update(email, token string) error
FindByStatus(status string) ([]Subscriber, error)
Confirm(token string) (string, error)
Unsubscribe(email string) error
}
SubscriptionService is the interface that wraps methods related to subscribe function
Click to show internal directories.
Click to hide internal directories.