models

package
v0.2.24 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

models/mailbox.go

Index

Constants

View Source
const (
	MAILBOX_IMAP_PORT     = 993
	MAILBOX_IMAP_SERVER   = "mail.hostedemail.com"
	MAILBOX_IMAP_SECURITY = enum.EmailSecurityTLS

	MAILBOX_SMTP_PORT     = 587
	MAILBOX_SMTP_SERVER   = "mail.hostedemail.com"
	MAILBOX_SMTP_SECURITY = enum.EmailSecurityTLS

	MAILBOX_INBOX = "INBOX"
	MAILBOX_SENT  = "Sent Items"
	MAILBOX_SPAM  = "Spam"

	MAILBOX_GOOGLE_IMAP_SERVER   = "imap.gmail.com"
	MAILBOX_GOOGLE_IMAP_PORT     = 993
	MAILBOX_GOOGLE_IMAP_SECURITY = enum.EmailSecurityTLS
	MAILBOX_GOOGLE_INBOX         = "INBOX"
	MAILBOX_GOOGLE_SENT          = "[Gmail]/Sent Mail"
	MAILBOX_GOOGLE_SPAM          = "[Gmail]/Spam"
)

Variables

This section is empty.

Functions

func DecryptToken added in v0.2.16

func DecryptToken(key string, encryptedToken string) (string, error)

Decrypt a token using AES-GCM

func EncryptToken added in v0.2.16

func EncryptToken(key string, token string) (string, error)

Encrypt a token using AES-GCM

func SetupTimescaleDB added in v0.2.5

func SetupTimescaleDB(db *gorm.DB) error

SetupTimescaleDB initializes the TimescaleDB specifics for this model

Types

type DMARCMonitoring added in v0.0.3

type DMARCMonitoring struct {
	ID            string    `gorm:"primary_key;type:uuid;default:gen_random_uuid()" json:"id"`
	Tenant        string    `gorm:"column:tenant;type:varchar(255);NOT NULL" json:"tenant"`
	CreatedAt     time.Time `gorm:"column:created_at;type:timestamp;DEFAULT:current_timestamp" json:"createdAt"`
	EmailProvider string    `gorm:"column:email_provider;type:varchar(255)" json:"emailProvider"`
	Domain        string    `gorm:"column:domain;type:varchar(255)" json:"domain"`
	ReportStart   time.Time `gorm:"column:report_start;type:timestamp" json:"reportStart"`
	ReportEnd     time.Time `gorm:"column:report_end;type:timestamp" json:"reportEnd"`
	MessageCount  int       `gorm:"column:message_count;type:integer" json:"messageCount"`
	SPFPass       int       `gorm:"column:spf_pass;type:integer" json:"spfPass"`
	DKIMPass      int       `gorm:"column:dkim_pass;type:integer" json:"dkimPass"`
	DMARCPass     int       `gorm:"column:dmarc_pass;type:integer" json:"dmarcPass"`
	Data          string    `gorm:"type:text"`
}

func (DMARCMonitoring) TableName added in v0.0.3

func (DMARCMonitoring) TableName() string

type Domain added in v0.0.3

type Domain struct {
	ID          uint64    `gorm:"primary_key;autoIncrement" json:"id"`
	Tenant      string    `gorm:"column:tenant;type:varchar(255);NOT NULL" json:"tenant"`
	Domain      string    `gorm:"column:domain;type:varchar(255);NOT NULL;uniqueIndex" json:"domain"`
	Configured  bool      `gorm:"column:configured;type:boolean;NOT NULL;DEFAULT:false" json:"configured"`
	CreatedAt   time.Time `gorm:"column:created_at;type:timestamp;DEFAULT:current_timestamp" json:"createdAt"`
	UpdatedAt   time.Time `gorm:"column:updated_at;type:timestamp;DEFAULT:current_timestamp" json:"updatedAt"`
	Active      bool      `gorm:"column:active;type:boolean;NOT NULL;DEFAULT:true" json:"active"`
	DkimPublic  string    `gorm:"column:dkim_public;type:text" json:"dkimPublic"`
	DkimPrivate string    `gorm:"column:dkim_private;type:text" json:"dkimPrivate"`
}

func (Domain) TableName added in v0.0.3

func (Domain) TableName() string

type Email

type Email struct {
	ID        string              `gorm:"column:id;type:varchar(50);primaryKey" json:"id"`
	MailboxID string              `gorm:"column:mailbox_id;type:varchar(50);index;not null" json:"mailboxId"`
	Direction enum.EmailDirection `gorm:"column:direction;type:varchar(20);index;not null" json:"direction"`
	Status    enum.EmailStatus    `gorm:"column:status;type:varchar(20);index" json:"status"`
	MessageID string              `gorm:"column:message_id;uniqueIndex;type:varchar(255);not null" json:"messageId"`
	ThreadID  string              `gorm:"column:thread_id;type:varchar(255);index" json:"threadId"`

	// Core email metadata
	Subject      string         `gorm:"column:subject;type:varchar(1000)" json:"subject"`
	FromAddress  string         `gorm:"column:from_address;type:varchar(255);index" json:"fromAddress"`
	FromName     string         `gorm:"column:from_name;type:varchar(255)" json:"fromName"`
	FromUser     string         `gorm:"column:from_user;type:varchar(255)" json:"fromUser"`
	FromDomain   string         `gorm:"column:from_domain;type:varchar(255)" json:"fromDomain"`
	ReplyTo      string         `gorm:"column:reply_to;type:varchar(255);index" json:"replyTo"`
	ToAddresses  pq.StringArray `gorm:"column:to_addresses;type:text[]" json:"toAddresses"`
	CcAddresses  pq.StringArray `gorm:"column:cc_addresses;type:text[]" json:"ccAddresses"`
	BccAddresses pq.StringArray `gorm:"column:bcc_addresses;type:text[]" json:"bccAddresses"`
	TrackClicks  bool           `gorm:"column:track_clicks;default:false" json:"trackClicks"`
	IsViewed     bool           `gorm:"column:isViewed;default:false" json:"isViewed"`
	EmailKey     string         `gorm:"column:email_key;type:text;not null" json:"emailKey"`

	Folder string `gorm:"column:folder;type:varchar(100)" json:"folder"`

	// Content
	Body          string `gorm:"column:body;type:text" json:"body"`
	HasAttachment bool   `gorm:"column:has_attachment;default:false" json:"hasAttachment"`

	// Send Details
	StatusDetail string `gorm:"column:status_detail;type:text" json:"statusDetail"` // Error message or delivery info
	SendAttempts int    `gorm:"column:send_attempts;default:0" json:"sendAttempts"` // Number of send attempts

	// Time information
	SentAt        *time.Time `gorm:"column:sent_at;type:timestamp;index" json:"sentAt"`
	ReceivedAt    *time.Time `gorm:"column:received_at;type:timestamp;index" json:"receivedAt"`
	LastAttemptAt *time.Time `gorm:"column:last_attempt_at;type:timestamp" json:"lastAttemptAt"`    // When last send attempt occurred
	ScheduledFor  *time.Time `gorm:"column:scheduled_for;type:timestamp;index" json:"scheduledFor"` // For scheduled sends

	// Standard timestamps
	CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:current_timestamp" json:"createdAt"`
	UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:current_timestamp" json:"updatedAt"`
}

Email represents a raw email message stored in the database

func (*Email) AllRecipients added in v0.0.3

func (e *Email) AllRecipients() []string

func (*Email) BeforeCreate

func (e *Email) BeforeCreate(tx *gorm.DB) error

func (Email) TableName

func (Email) TableName() string

type EmailAttachment

type EmailAttachment struct {
	ID          string         `gorm:"column:id;type:varchar(50);primaryKey"`
	EmailIDs    pq.StringArray `gorm:"column:email_ids;type:varchar(50)[];index;not null"`
	Filename    string         `gorm:"column:filename;type:varchar(500)"`
	ContentType string         `gorm:"column:content_type;type:varchar(255)"`
	ContentID   string         `gorm:"column:content_id;type:varchar(255)"` // For inline attachments
	Size        int            `gorm:"column:size;default:0"`
	IsInline    bool           `gorm:"column:is_inline;default:false"`

	// Storage options
	StorageService string `gorm:"column:storage_service;type:varchar(50)"` // "s3", "azure", "local", etc.
	StorageBucket  string `gorm:"column:storage_bucket;type:varchar(255)"` // For cloud storage
	StorageKey     string `gorm:"column:storage_key;type:varchar(1000)"`   // If stored in S3/blob storage

	// Security and verification
	ContentHash string `gorm:"column:content_hash;type:varchar(64);index"` // SHA-256 hash of content

	// Standard timestamps
	CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:current_timestamp" json:"createdAt"`
	UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:current_timestamp" json:"updatedAt"`
}

EmailAttachment represents an attachment to an email

func (*EmailAttachment) BeforeCreate

func (e *EmailAttachment) BeforeCreate(tx *gorm.DB) error

func (EmailAttachment) TableName

func (EmailAttachment) TableName() string

TableName overrides the table name for EmailAttachment

type EmailEvent added in v0.2.4

type EmailEvent struct {
	ID             string                   `gorm:"column:id;type:varchar(50);primaryKey;not null" json:"id"`
	Event          enum.EmailEvent          `gorm:"column:event;type:varchar(50);index;not null" json:"event"`
	Publisher      enum.MailstackService    `gorm:"column:publisher;type:varchar(50);index;not null" json:"publisher"`
	Timestamp      time.Time                `gorm:"not null;index"`
	Tenant         string                   `gorm:"column:tenant;type:varchar(50);index;not null" json:"tenant"`
	User           string                   `gorm:"column:user;type:varchar(50);index;not null" json:"user"`
	EmailID        string                   `gorm:"column:email_id;type:varchar(50);index;not null" json:"emailId"`
	MailboxID      string                   `gorm:"column:mailbox_id;type:varchar(50);index;not null" json:"mailboxId"`
	ThreadID       string                   `gorm:"column:thread_id;type:varchar(255);index" json:"threadId"`
	Direction      enum.EmailDirection      `gorm:"column:direction;type:text;not null" json:"direction"`
	Classification enum.EmailClassification `gorm:"column:classification;type:text"`
	Payload        []byte                   `gorm:"column:payload;type:bytea" json:"-"`
	HasError       bool                     `gorm:"column:has_error;type:boolean" json:"hasError"`
	ErrorMessage   string                   `gorm:"column:error_message;type:varchar(255)" json:"errorMessage"`
}

EmailEvent represents the main email events table

func (*EmailEvent) BeforeCreate added in v0.2.4

func (e *EmailEvent) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook to ensure the timestamp is set

func (EmailEvent) TableName added in v0.2.4

func (EmailEvent) TableName() string

TableName overrides the table name

type EmailLog added in v0.2.5

type EmailLog struct {
	// Primary identifiers
	ID        string `gorm:"primaryKey;column:id;index" json:"id"`
	MailboxID string `gorm:"column:mailbox_id;index" json:"mailboxId"`
	MessageID string `gorm:"column:message_id;uniqueIndex" json:"messageId"`
	ThreadID  string `gorm:"column:thread_id;index" json:"threadId"`

	// Email metadata
	Direction    enum.EmailDirection `gorm:"column:direction;type:varchar(10)" json:"direction"`
	Status       enum.EmailStatus    `gorm:"column:status;type:varchar(20)" json:"status"`
	StatusDetail string              `gorm:"column:status_detail" json:"statusDetail"`
	EmailHash    string              `gorm:"column:email_hash;index" json:"emailHash"`
	EMLKey       string              `gorm:"column:eml_key" json:"emlKey"`

	// Core email content
	Subject       string         `gorm:"column:subject;type:text" json:"subject"`
	CleanSubject  string         `gorm:"column:clean_subject;type:text" json:"cleanSubject"`
	FromAddress   string         `gorm:"column:from_address" json:"fromAddress"`
	FromName      string         `gorm:"column:from_name" json:"fromName"`
	FromUser      string         `gorm:"column:from_user" json:"fromUser"`
	FromDomain    string         `gorm:"column:from_domain" json:"fromDomain"`
	ReplyTo       string         `gorm:"column:reply_to" json:"replyTo"`
	ToAddresses   pq.StringArray `gorm:"column:to_addresses;type:text[]" json:"toAddresses"`
	CcAddresses   pq.StringArray `gorm:"column:cc_addresses;type:text[]" json:"ccAddresses"`
	BccAddresses  pq.StringArray `gorm:"column:bcc_addresses;type:text[]" json:"bccAddresses"`
	AttachmentIDs pq.StringArray `gorm:"column:attachment_ids;type:text[]" json:"attachments"`

	// Content fields
	BodyMarkdown  string `gorm:"column:body_markdown;type:text" json:"bodyMarkdown"`
	HasAttachment bool   `gorm:"column:has_attachment" json:"hasAttachment"`
	HasSignature  bool   `gorm:"column:has_signature" json:"hasSignature"`

	// Engagement metrics
	TrackClicks bool `gorm:"column:track_clicks" json:"trackClicks"`

	// Classification
	Classification       enum.EmailClassification `gorm:"column:classification;type:varchar(30)" json:"classification"`
	ClassificationReason string                   `gorm:"column:classification_reason" json:"classificationReason"`

	// Time information
	SentAt        *time.Time `gorm:"column:sent_at" json:"sentAt,omitempty"`
	ReceivedAt    *time.Time `gorm:"column:received_at" json:"receivedAt,omitempty"`
	LastAttemptAt *time.Time `gorm:"column:last_attempt_at" json:"lastAttemptAt,omitempty"`
	ScheduledFor  *time.Time `gorm:"column:scheduled_for" json:"scheduledFor,omitempty"`
	CreatedAt     time.Time  `gorm:"column:created_at;autoCreateTime" json:"createdAt"`
	UpdatedAt     time.Time  `gorm:"column:updated_at;autoUpdateTime" json:"updatedAt"`
}

func (EmailLog) TableName added in v0.2.5

func (EmailLog) TableName() string

TableName specifies the table name for the EmailRecord model

type EmailMessage added in v0.0.3

type EmailMessage struct {
	ID        uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey"`
	CreatedAt time.Time `gorm:"column:created_at;type:timestamp;DEFAULT:current_timestamp"`

	Status EmailMessageStatus `gorm:"size:50;not null;"`

	SentAt *time.Time `gorm:"column:sent_at;type:timestamp;"`
	Error  *string    `gorm:"column:error;type:text"`

	UniqueInternalIdentifier *string `gorm:"size:255;index:unique_internal_identifier"`

	Tenant       string `gorm:"size:255;not null;index:idx_raw_email_external_system"`
	ProducerId   string `gorm:"size:255;not null;"`
	ProducerType string `gorm:"size:255;not null;"`

	//Email message data
	FromName     string   `gorm:"size:255;"`
	From         string   `gorm:"size:255;"`
	FromProvider string   `gorm:"size:255;"`
	To           []string `gorm:"-"`
	ToString     string   `gorm:"type:text;column:to"`
	Cc           []string `gorm:"-"`
	CcString     string   `gorm:"type:text;column:cc"`
	Bcc          []string `gorm:"-"`
	BccString    string   `gorm:"type:text;column:bcc"`
	Subject      string
	Content      string

	//COS interaction event id
	//deprecated
	ReplyTo *string

	//Values taken from providers
	ProviderMessageId  string `gorm:"size:255;not null;"`
	ProviderThreadId   string `gorm:"size:255;not null;"`
	ProviderInReplyTo  string `gorm:"size:255;not null;"`
	ProviderReferences string `gorm:"size:255;not null;"`
}

func (*EmailMessage) AfterFind added in v0.0.3

func (e *EmailMessage) AfterFind(tx *gorm.DB) (err error)

AfterFind hook for converting strings to slices

func (*EmailMessage) BeforeSave added in v0.0.3

func (e *EmailMessage) BeforeSave(tx *gorm.DB) (err error)

BeforeSave hook for converting slices to strings

func (EmailMessage) TableName added in v0.0.3

func (EmailMessage) TableName() string

type EmailMessageStatus added in v0.0.3

type EmailMessageStatus string
const (
	EmailMessageStatusScheduled EmailMessageStatus = "SCHEDULED"
	EmailMessageStatusSent      EmailMessageStatus = "SENT"
	EmailMessageStatusProcessed EmailMessageStatus = "PROCESSED"
	EmailMessageStatusError     EmailMessageStatus = "ERROR"
)

type EmailThread

type EmailThread struct {
	ID             string         `gorm:"column:id;type:varchar(50);primaryKey" json:"id"`
	MailboxID      string         `gorm:"column:mailbox_id;type:varchar(50);index" json:"mailboxId"`
	Subject        string         `gorm:"column:subject;type:varchar(1000)" json:"subject"`
	Summary        string         `gorm:"column:summary;type:varchar(1000)" json:"summary"`
	Participants   pq.StringArray `gorm:"column:participants;type:text[]" json:"participants"`
	LastMessageID  string         `gorm:"column:last_message_id;type:varchar(255)" json:"lastMessageId"`
	IsDone         bool           `gorm:"column:isDone;default:false" json:"isDone"`
	LastMessageAt  *time.Time     `gorm:"column:last_message_at;type:timestamp" json:"lastMessageAt"`
	FirstMessageAt *time.Time     `gorm:"column:first_message_at;type:timestamp" json:"firstMessageAt"`
	CreatedAt      time.Time      `gorm:"column:created_at;type:timestamp;DEFAULT:current_timestamp" json:"createdAt"`
	UpdatedAt      time.Time      `gorm:"column:updated_at;type:timestamp;DEFAULT:current_timestamp" json:"updatedAt"`
}

func (*EmailThread) BeforeCreate

func (e *EmailThread) BeforeCreate(*gorm.DB) error

func (EmailThread) TableName

func (EmailThread) TableName() string

type JSONMap

type JSONMap map[string]interface{}

JSONMap represents a JSON object that can be stored in PostgreSQL

func (*JSONMap) Scan

func (j *JSONMap) Scan(value interface{}) error

Scan implements the sql.Scanner interface for JSONMap

func (JSONMap) Value

func (j JSONMap) Value() (driver.Value, error)

Value implements the driver.Valuer interface for JSONMap

type MailStackDomain added in v0.0.3

type MailStackDomain struct {
	ID          uint64    `gorm:"primary_key;autoIncrement" json:"id"`
	Tenant      string    `gorm:"column:tenant;type:varchar(255);NOT NULL" json:"tenant"`
	Domain      string    `gorm:"column:domain;type:varchar(255);NOT NULL;uniqueIndex" json:"domain"`
	Configured  bool      `gorm:"column:configured;type:boolean;NOT NULL;DEFAULT:false" json:"configured"`
	CreatedAt   time.Time `gorm:"column:created_at;type:timestamp;DEFAULT:current_timestamp" json:"createdAt"`
	UpdatedAt   time.Time `gorm:"column:updated_at;type:timestamp" json:"updatedAt"`
	Active      bool      `gorm:"column:active;type:boolean;NOT NULL;DEFAULT:true" json:"active"`
	DkimPublic  string    `gorm:"column:dkim_public;type:text" json:"dkimPublic"`
	DkimPrivate string    `gorm:"column:dkim_private;type:text" json:"dkimPrivate"`
}

TODO: Deprecated, drop in favor of Domain model

func (MailStackDomain) TableName added in v0.0.3

func (MailStackDomain) TableName() string

type MailStackDomainConfiguration added in v0.0.3

type MailStackDomainConfiguration struct {
}

type Mailbox

type Mailbox struct {
	ID            string             `gorm:"column:id;type:varchar(50);primaryKey" json:"id"`
	Tenant        string             `gorm:"column:tenant;type:varchar(255)" json:"tenant"`
	UserID        string             `gorm:"column:user_id;type:varchar(255);index" json:"userId"`
	Provider      enum.EmailProvider `gorm:"column:provider;type:varchar(50);index;not null" json:"provider"`
	EmailAddress  string             `gorm:"column:email_address;type:varchar(255);index" json:"emailAddress"`
	MailboxUser   string             `gorm:"column:mailbox_user;type:varchar(255);index" json:"mailboxUser"`
	MailboxDomain string             `gorm:"column:mailbox_domain;type:varchar(255);index" json:"mailboxDomain"`
	SenderID      string             `gorm:"column:sender_id;type:varchar(255);index" json:"senderId"`

	// Common connection properties
	InboundEnabled  bool `gorm:"column:inbound_enabled;default:true" json:"inboundEnabled"`
	OutboundEnabled bool `gorm:"column:outbound_enabled;default:true" json:"outboundEnabled"`

	// Protocol-specific configurations (null for API-based providers)
	ImapServer   string             `gorm:"column:imap_server;type:varchar(255)" json:"imapServer"`
	ImapPort     int                `gorm:"column:imap_port" json:"imapPort"`
	ImapUsername string             `gorm:"column:imap_username;type:varchar(255)" json:"imapUsername"`
	ImapPassword string             `gorm:"column:imap_password;type:varchar(255)" json:"imapPassword"`
	ImapSecurity enum.EmailSecurity `gorm:"column:imap_security;type:varchar(50)" json:"imapSecurity"`

	SmtpServer   string             `gorm:"column:smtp_server;type:varchar(255)" json:"smtpServer"`
	SmtpPort     int                `gorm:"column:smtp_port" json:"smtpPort"`
	SmtpUsername string             `gorm:"column:smtp_username;type:varchar(255)" json:"smtpUsername"`
	SmtpPassword string             `gorm:"column:smtp_password;type:varchar(255)" json:"smtpPassword"`
	SmtpSecurity enum.EmailSecurity `gorm:"column:smtp_security;type:varchar(50)" json:"smtpSecurity"`

	// OAuth specific fields (for Google, Microsoft, etc.)
	OAuthClientID           string     `gorm:"column:oauth_client_id;type:varchar(255)" json:"oauthClientId"`
	OAuthClientSecret       string     `gorm:"column:oauth_client_secret;type:varchar(255)" json:"oauthClientSecret"`
	OAuthRefreshToken       string     `gorm:"column:oauth_refresh_token;type:varchar(1000)" json:"oauthRefreshToken"`
	OAuthAccessToken        string     `gorm:"column:oauth_access_token;type:varchar(1000)" json:"oauthAccessToken"`
	OAuthTokenExpiry        *time.Time `gorm:"column:oauth_token_expiry;type:timestamp" json:"oauthTokenExpiry"`
	OAuthScope              string     `gorm:"column:oauth_scope;type:varchar(2000)" json:"oauthScope"`
	OAuthTokenId            string     `gorm:"column:oauth_token_id;type:varchar(2000)" json:"oauthTokenId"`
	OAuthNeedsManualRefresh bool       `gorm:"column:oauth_needs_manual_refresh;default:false;"`
	OAuthRevokedAt          *time.Time `gorm:"column:oauth_revoked_at;type:timestamp" json:"oauthRevokedAt"`

	// Email sending configuration
	ReplyToAddress string `gorm:"column:reply_to_address;type:varchar(255)" json:"replyToAddress"`

	// Sync configuration
	SyncFolders pq.StringArray `gorm:"column:sync_folders;type:text[]" json:"syncFolders"`

	// Status tracking
	ConnectionStatus    enum.ConnectionStatus `gorm:"column:connection_status;type:varchar(50)" json:"connectionStatus"`
	LastConnectionCheck *time.Time            `gorm:"column:last_connection_check;type:timestamp" json:"lastConnectionCheck"`
	ErrorMessage        string                `gorm:"column:error_message;type:text" json:"errorMessage"`

	// Send rate limits
	DailySendQuota int        `gorm:"column:daily_quota;default:2000" json:"dailyQuota"`
	DailySendCount int        `gorm:"column:daily_send_count;default:0" json:"dailySendCount"`
	QuotaResetAt   *time.Time `gorm:"column:quota_reset_at;type:timestamp" json:"quotaResetAt"`

	// Distributed processing fields
	ProcessingPodID       string     `gorm:"column:processing_pod_id;type:varchar(255)" json:"processingPodId"`
	ProcessingStartedAt   *time.Time `gorm:"column:processing_started_at;type:timestamp" json:"processingStartedAt"`
	ProcessingHeartbeatAt *time.Time `gorm:"column:processing_heartbeat_at;type:timestamp" json:"processingHeartbeatAt"`
	ProcessingRunCount    int        `gorm:"column:processing_run_count;type:integer;default:0" json:"processingRunCount"`

	// Standard timestamps
	CreatedAt time.Time      `gorm:"column:created_at;type:timestamp;default:current_timestamp" json:"createdAt"`
	UpdatedAt time.Time      `gorm:"column:updated_at;type:timestamp;default:current_timestamp" json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index" json:"-"`

	// Fields from previous mailbox model
	ProvisionStatus         MailboxProvisionStatus `gorm:"column:provision_status;type:varchar(255)" json:"provisionStatus"`
	MinMinutesBetweenEmails int                    `gorm:"type:integer" json:"minMinutesBetweenEmails"`
	MaxMinutesBetweenEmails int                    `gorm:"type:integer" json:"maxMinutesBetweenEmails"`
	ConfigureAttemptAt      *time.Time             `gorm:"column:configure_attempt_at;type:timestamp" json:"configureAttemptAt"`
	LastRampUpAt            time.Time              `gorm:"column:last_ramp_up_at;type:timestamp" json:"lastRampUpAt"`
	RampUpRate              int                    `gorm:"type:integer" json:"rampUpRate"`
	RampUpMax               int                    `gorm:"type:integer" json:"rampUpMax"`
	RampUpCurrent           int                    `gorm:"type:integer" json:"rampUpCurrent"`
	ForwardingTo            string                 `gorm:"column:forwarding_to;type:text" json:"forwardingTo"`
	WebmailEnabled          bool                   `gorm:"column:webmail_enabled;type:boolean" json:"webmailEnabled"`
}

Mailbox represents an email account configuration with provider-specific settings

func (*Mailbox) BeforeCreate

func (m *Mailbox) BeforeCreate(*gorm.DB) error

func (Mailbox) TableName

func (Mailbox) TableName() string

TableName sets the table name for the Mailbox model

type MailboxProvisionStatus added in v0.1.16

type MailboxProvisionStatus string
const (
	MailboxStatusPendingProvisioning MailboxProvisionStatus = "PENDING_PROVISIONING"
	MailboxStatusProvisioned         MailboxProvisionStatus = "PROVISIONED"
)

type MailboxSyncState

type MailboxSyncState struct {
	ID         string    `gorm:"column:id;type:varchar(50);primaryKey"`
	MailboxID  string    `gorm:"column:mailbox_id;type:varchar(50);index;not null"`
	FolderName string    `gorm:"column:folder_name;type:varchar(100);index;not null"`
	LastUID    uint32    `gorm:"column:last_uid;not null"`
	LastSync   time.Time `gorm:"column:last_sync;type:timestamp"`
	CreatedAt  time.Time `gorm:"column:created_at;type:timestamp;default:current_timestamp"`
	UpdatedAt  time.Time `gorm:"column:updated_at;type:timestamp;default:current_timestamp"`
}

MailboxSyncState represents the synchronization state for a mailbox folder

func (*MailboxSyncState) BeforeCreate added in v0.0.3

func (m *MailboxSyncState) BeforeCreate(tx *gorm.DB) error

func (MailboxSyncState) TableName

func (MailboxSyncState) TableName() string

type MailstackReputation added in v0.0.3

type MailstackReputation struct {
	ID                  string    `gorm:"primary_key;type:uuid;default:gen_random_uuid()" json:"id"`
	Tenant              string    `gorm:"column:tenant;type:varchar(255);NOT NULL" json:"tenant"`
	CreatedAt           time.Time `gorm:"column:created_at;type:timestamp;DEFAULT:current_timestamp" json:"createdAt"`
	Domain              string    `gorm:"column:domain;type:varchar(255)" json:"domain"`
	DomainAgePenalty    int       `gorm:"column:domain_age_penalty;type:integer" json:"domainAgePenalty"`
	BlacklistPenaltyPct int       `gorm:"column:blacklist_penalty_pct;type:integer" json:"blacklistPenaltyPct"`
	BouncePenaltyPct    int       `gorm:"column:bounce_penalty_pct;type:integer" json:"bouncePenaltyPct"`
	DMARCPenaltyPct     int       `gorm:"column:dmarc_penalty_pct;type:integer" json:"dmarcPenaltyPct"`
	SPFPenaltyPct       int       `gorm:"column:spf_penalty_pct;type:integer" json:"spfPenaltyPct"`
}

func (MailstackReputation) TableName added in v0.0.3

func (MailstackReputation) TableName() string

type OrphanEmail added in v0.0.3

type OrphanEmail struct {
	ID           string    `gorm:"column:id;type:varchar(50);primaryKey"`
	MessageID    string    `gorm:"column:message_id;type:varchar(255);uniqueIndex"`
	ReferencedBy string    `gorm:"column:referenced_by;type:varchar(255)"` // Email ID that referenced this
	ThreadID     string    `gorm:"column:thread_id;type:varchar(50);index"`
	MailboxID    string    `gorm:"column:mailbox_id;type:varchar(50);index"`
	CreatedAt    time.Time `gorm:"column:created_at;type:timestamp;default:current_timestamp"`
}

func (*OrphanEmail) BeforeCreate added in v0.0.3

func (m *OrphanEmail) BeforeCreate(tx *gorm.DB) error

func (OrphanEmail) TableName added in v0.0.3

func (OrphanEmail) TableName() string

type Sender added in v0.0.22

type Sender struct {
	ID             string    `gorm:"column:id;type:varchar(50);primaryKey" json:"id"`
	Tenant         string    `gorm:"column:tenant;type:varchar(255)" json:"tenant"`
	UserID         string    `gorm:"column:user_id;type:varchar(255);index" json:"userId"`
	DisplayName    string    `gorm:"column:display_name;type:varchar(255)" json:"displayName"`
	SignatureHTML  string    `gorm:"column:signature_html;type:text" json:"signatureHtml"`
	SignaturePlain string    `gorm:"column:signature_plain;type:text" json:"signaturePlain"`
	IsDefault      bool      `gorm:"column:is_default;type:boolean" json:"isDefault"`
	IsActive       bool      `gorm:"column:is_active;type:boolean" json:"isActive"`
	CreatedAt      time.Time `gorm:"column:created_at;type:timestamp;default:current_timestamp" json:"createdAt"`
	UpdatedAt      time.Time `gorm:"column:updated_at;type:timestamp;default:current_timestamp" json:"updatedAt"`
}

func (*Sender) BeforeCreate added in v0.0.22

func (m *Sender) BeforeCreate(tx *gorm.DB) error

func (Sender) TableName added in v0.0.22

func (Sender) TableName() string

Jump to

Keyboard shortcuts

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