types

package
v0.0.0-...-db09f8a Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermissionSendMail       = "send_mail"
	PermissionManageClient   = "manage_client"
	PermissionManageUser     = "manage_user"
	PermissionManageTemplate = "manage_template"
	ClientIdPrefixLength     = 8
)
View Source
const (
	MailPattern      = "[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+"
	EmailAddrPattern = ".*\\s<(" + MailPattern + ")>|(" + MailPattern + ")"
)
View Source
const (
	VerificationScopeUser   = "scope_user"
	VerificationScopeSender = "scope_sender_address"
)

Variables

This section is empty.

Functions

func AllPermissions

func AllPermissions() []string

func NewClientApiKey

func NewClientApiKey(pepper string) (key, hash string)

func NewClientId

func NewClientId() string

func NewClientIdFrom

func NewClientIdFrom(base string) string

Types

type ApplicationEvent

type ApplicationEvent struct {
	Type      EventType   `json:"event_type"`
	UserId    string      `json:"user_id" boltholdIndex:"UserId"`
	ClientId  string      `json:"client_id" boltholdIndex:"ClientId"`
	CreatedAt time.Time   `json:"created_at"`
	Payload   interface{} `json:"payload"`
}

type Client

type Client struct {
	ID          string      `json:"id" boltholdKey:"ID"`
	Description string      `json:"description"`
	UserId      string      `json:"user_id" boltholdIndex:"UserId"`
	Permissions []string    `json:"permissions"`
	Sender      MailAddress `json:"sender"`
	ApiKey      *string     `json:"api_key"` // caution: usually you want to hide this!
	CreatedAt   time.Time   `json:"created_at"`
	CountMails  int         `json:"count_mails"` // not persisted
}

func (*Client) DefaultSender

func (c *Client) DefaultSender(baseDomain string) MailAddress

func (*Client) HasPermission

func (c *Client) HasPermission(permission string) bool

func (*Client) HasPermissionAnyOf

func (c *Client) HasPermissionAnyOf(permissions []string) bool

func (*Client) Sanitize

func (c *Client) Sanitize(baseDomain string) *Client

func (*Client) SenderOrDefault

func (c *Client) SenderOrDefault(baseDomain string) MailAddress

func (*Client) Validate

func (c *Client) Validate() error

func (*Client) WithMailCount

func (c *Client) WithMailCount(count int) *Client

type EventType

type EventType int
const (
	MailSent EventType = iota
)

type Mail

type Mail struct {
	From      MailAddress
	To        MailAddresses
	Subject   string
	Body      string
	Type      string
	Date      time.Time
	MessageID string
}

func (*Mail) Reader

func (m *Mail) Reader() *strings.Reader

func (*Mail) Sanitized

func (m *Mail) Sanitized() *Mail

func (*Mail) String

func (m *Mail) String() string

func (*Mail) WithHTML

func (m *Mail) WithHTML(html string) *Mail

func (*Mail) WithText

func (m *Mail) WithText(text string) *Mail

type MailAddress

type MailAddress string

func (MailAddress) Domain

func (m MailAddress) Domain() string

func (MailAddress) Raw

func (m MailAddress) Raw() string

func (MailAddress) String

func (m MailAddress) String() string

func (MailAddress) Valid

func (m MailAddress) Valid() bool

type MailAddresses

type MailAddresses []MailAddress

func (MailAddresses) RawStrings

func (m MailAddresses) RawStrings() []string

func (MailAddresses) Strings

func (m MailAddresses) Strings() []string

type MailSendRequest

type MailSendRequest struct {
	To           MailAddresses     `json:"to"`
	Subject      string            `json:"subject"`
	Text         string            `json:"text"`
	Html         string            `json:"html"`
	TemplateId   string            `json:"template_id"`
	TemplateVars map[string]string `json:"template_vars"`
}

type MailSentPayload

type MailSentPayload struct {
	From MailAddress   `json:"from"`
	To   MailAddresses `json:"to"`
	Size int           `json:"size"`
}

func (*MailSentPayload) FromMail

func (p *MailSentPayload) FromMail(mail *Mail) *MailSentPayload

type SenderAddress

type SenderAddress struct {
	MailAddress `json:"mail"`
	Verified    bool `json:"verified"`
}

type Template

type Template struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	UserId  string `json:"user_id" boltholdIndex:"UserId"`
	Content string `json:"content"`
}

func (*Template) FillContent

func (t *Template) FillContent(vars map[string]string) string

func (*Template) GuessIsHtml

func (t *Template) GuessIsHtml() bool

type User

type User struct {
	ID        string          `json:"id" boltholdKey:"ID"`
	Password  string          `json:"password"` // clear before returning in a response !
	Senders   []SenderAddress `json:"senders"`
	Verified  bool            `json:"verified"`
	CreatedAt time.Time       `json:"created_at"`
}

func (*User) HasSender

func (u *User) HasSender(sender MailAddress) bool

func (*User) HasVerifiedSender

func (u *User) HasVerifiedSender(sender MailAddress) bool

func (*User) IsValid

func (u *User) IsValid() bool

func (*User) Sanitize

func (u *User) Sanitize() *User

type Verification

type Verification struct {
	Token   string `json:"token" boltholdKey:"Token"`
	UserId  string `json:"user_id"`
	Scope   string `json:"scope"`
	Subject string `json:"subject"`
}

func NewVerification

func NewVerification(user *User, scope, subject string) *Verification

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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