models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAddressFormat is used for addresses of zero length or without
	// an "@" sign.
	ErrInvalidAddressFormat = errors.New("address: invalid format")

	// ErrPathTooLong is used for addresses, that are too long or contain a path
	// that is too long according to RFC#5321.
	ErrPathTooLong = errors.New("address: path too long")

	// ZeroAddress is an invalid, zero value Address.
	ZeroAddress Address
)

Functions

func DomainToASCII

func DomainToASCII(domain string) (string, error)

DomainToASCII transforms a unicode domain to punycode.

func DomainToUnicode

func DomainToUnicode(domain string) (string, error)

DomainToUnicode normalizes a punycode domain to unicode and applies the NFC normal form.

func NormalizeLocalPart

func NormalizeLocalPart(localPart string) string

NormalizeLocalPart applie several rules to make the local-part of addresses comparable. This may only be applied to local addresses. Outbound addresses may not be altered.

1) The local-part is case-folded so that "user" and "USER" are considered equal. 2) The local-part is normalized using NFKC so that equal looking runes are considered equal. 3) The local-part has the suffix trimmed. A suffix is everything after the first '+' rune.

Types

type Address

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

Address is a string of the form "local-part@domain".

func Parse

func Parse(raw string) (Address, error)

Parse splits an address at the "@" sign and checks for size limits.

func ParseNormalized

func ParseNormalized(raw string) (Address, error)

ParseNormalized calls ParseUnicode and transforms the local-part using NormalizeLocalPart.

func ParseUnicode

func ParseUnicode(raw string) (Address, error)

ParseUnicode calls Parse and transforms the domain part of the address using DomainToUnicode.

func (Address) Domain

func (a Address) Domain() string

Domain return the part right of the "@" sign (exclusive).

func (Address) LocalPart

func (a Address) LocalPart() string

LocalPart returns the part left of the "@" sign (exclusive).

func (Address) Normalized

func (a Address) Normalized() Address

Normalized returns a copy of a with a normalized local-part.

func (*Address) Scan

func (a *Address) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (Address) String

func (a Address) String() string

String returns the raw address provided to ParseAddress.

func (Address) Value

func (a Address) Value() (driver.Value, error)

Value implements the sql/driver.Valuer interface.

type AddressEntity

type AddressEntity struct {
	ID        int64  `db:"id"`
	LocalPart string `db:"local_part"`
	DomainID  int64  `db:"domain_id"`
	MailboxID int64  `db:"mailbox_id"`
}

AddressEntity is the entity for the "addresses" table.

type DeliveryStatus

type DeliveryStatus int

DeliveryStatus indicates the status of delivery per recipient.

const (

	// StatusFailed is a mail that could not be delivered after the final attempt.
	StatusFailed DeliveryStatus
	// StatusDelivered is a mail that reached its final destination. This is either a successful
	// outbound transmission or a local mail, that has been retrieved.
	StatusDelivered
	// StatusInboxed is a mail delivered, but not deleted, to a local mailbox.
	StatusInboxed
	// StatusPending is a mail queued for outbound transmision.
	StatusPending
)

type DomainEntity

type DomainEntity struct {
	ID   int64  `db:"id"`
	Name string `db:"name"`
}

DomainEntity is the entity for the "domains" table.

type MailEntity

type MailEntity struct {
	ID              string        `db:"id"`
	ReceivedAt      int64         `db:"received_at"`
	DeletedAt       sql.NullInt64 `db:"deleted_at"`
	ReturnPath      Address       `db:"return_path"`
	Size            int64         `db:"size"`
	AttemptCount    int           `db:"attempt_count"`
	LastAttemptedAt sql.NullInt64 `db:"last_attempted_at"`
}

MailEntity is the entity for the "mails" table.

type MailboxCredentialEntity

type MailboxCredentialEntity struct {
	MailboxID int64  `db:"mailbox_id"`
	UpdatedAt int64  `db:"updated_at"`
	Hash      string `db:"hash"`
}

MailboxCredentialEntity is the entity for the "mailbox_credentials" table.

type MailboxEntity

type MailboxEntity struct {
	ID          int64  `db:"id"`
	DisplayName string `db:"display_name"`
}

MailboxEntity is the entity for the "mailboxes" table.

type RecipientEntity

type RecipientEntity struct {
	ID          int64          `db:"id"`
	MailID      string         `db:"mail_id"`
	MailboxID   sql.NullInt64  `db:"mailbox_id"`
	ForwardPath Address        `db:"forward_path"`
	Status      DeliveryStatus `db:"status"`
}

RecipientEntity is the entity for the "recipients" table.

Jump to

Keyboard shortcuts

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