models

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package models defines shared data structures for email operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatMessageID

func FormatMessageID(account, mailbox string, uid uint32) string

FormatMessageID creates a message ID from components.

func ParseMessageID

func ParseMessageID(id string) (string, string, uint32, error)

ParseMessageID extracts account, mailbox, and UID from a message ID. Format: {account}:{mailbox}:{uid} Parsing splits on first two colons only (mailbox names may contain colons).

Types

type AccountStatus

type AccountStatus struct {
	ID        string `json:"id"`
	Email     string `json:"email"`
	Connected bool   `json:"connected"`
	IsDefault bool   `json:"isDefault"`
}

AccountStatus represents the status of an email account.

type AttachmentInfo

type AttachmentInfo struct {
	Index       int    `json:"index"`
	Filename    string `json:"filename"`
	ContentType string `json:"contentType"`
	Size        int64  `json:"size"`
}

AttachmentInfo represents email attachment metadata.

type Email

type Email struct {
	ID              string           `json:"id"`
	Subject         string           `json:"subject"`
	From            string           `json:"from"`
	To              []string         `json:"to"`
	CC              []string         `json:"cc,omitempty"`
	BCC             []string         `json:"bcc,omitempty"`
	Date            string           `json:"date"`
	Body            string           `json:"body,omitempty"`
	ContentType     string           `json:"contentType,omitempty"`
	Mailbox         string           `json:"mailbox"`
	IsUnread        bool             `json:"isUnread"`
	IsFlagged       bool             `json:"isFlagged"`
	Attachments     []AttachmentInfo `json:"attachments,omitempty"`
	Account         string           `json:"account,omitempty"`
	MessageIDHeader string           `json:"messageIdHeader,omitempty"`
	InReplyTo       string           `json:"inReplyTo,omitempty"`
	References      []string         `json:"references,omitempty"`
}

Email represents an email message.

type EmailError

type EmailError string

EmailError is a string-based error type for email operations.

const (
	ErrInvalidMessageID   EmailError = "invalid message ID format"
	ErrAccountNotFound    EmailError = "account not found"
	ErrFolderNotFound     EmailError = "folder not found"
	ErrMessageNotFound    EmailError = "message not found"
	ErrAuthFailed         EmailError = "authentication failed"
	ErrConnectionFailed   EmailError = "connection failed"
	ErrTimeout            EmailError = "operation timed out"
	ErrFolderRoleNotFound EmailError = "folder role not found"
)

func (EmailError) Error

func (e EmailError) Error() string

type Folder

type Folder struct {
	Name   string     `json:"name"`
	Unread int        `json:"unread"`
	Total  int        `json:"total"`
	Role   FolderRole `json:"role,omitempty"`
}

Folder represents an email folder/mailbox.

type FolderRole

type FolderRole string

FolderRole represents the special-use purpose of a folder (RFC 6154).

const (
	RoleDrafts  FolderRole = "\\Drafts"
	RoleTrash   FolderRole = "\\Trash"
	RoleSent    FolderRole = "\\Sent"
	RoleJunk    FolderRole = "\\Junk"
	RoleArchive FolderRole = "\\Archive"
)

Jump to

Keyboard shortcuts

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