interfaces

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: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HEADER_TENANT = "X-Tenant"
	HEADER_USERID = "X-UserId"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudflareService added in v0.0.3

type CloudflareService interface {
	SetupDomainForMailStack(ctx context.Context, tenant, domain, destinationUrl string) ([]string, error)
	AddDNSRecord(ctx context.Context, zoneID, recordType, name, content string, ttl int, proxied bool, priority *int) error
	GetDNSRecords(ctx context.Context, domain string) (*[]DNSRecord, error)
	DeleteDNSRecord(ctx context.Context, zoneID string, recordID string) error
	CheckDomainExists(ctx context.Context, domain string) (bool, string, error)
}

type CreateMailboxRequest added in v0.0.3

type CreateMailboxRequest struct {
	Domain                string
	Username              string
	Password              string
	UserId                string
	WebmailEnabled        bool
	ForwardingTo          []string
	IgnoreDomainOwnership bool
	SenderID              string
}

type DNSRecord added in v0.0.3

type DNSRecord struct {
	ID      string `json:"id"`
	ZoneID  string `json:"zone_id"`
	Name    string `json:"zone_name"`
	Type    string `json:"type"`
	Content string `json:"content"`
}

type DomainService added in v0.0.3

type DomainService interface {
	ConfigureDomain(ctx context.Context, domain, redirectWebsite string) error
	GetDomain(ctx context.Context, domain string) (*models.MailStackDomain, error)
	CheckMailstackDomainReputations(ctx context.Context) error
	GetTenantForMailstackDomain(ctx context.Context, domain string) (string, error)
}

type EmailAttachmentRepository

type EmailAttachmentRepository interface {
	GetByID(ctx context.Context, id string) (*models.EmailAttachment, error)
	ListByEmail(ctx context.Context, emailID string) ([]*models.EmailAttachment, error)
	ListByThread(ctx context.Context, threadID string) ([]*models.EmailAttachment, error)
	Store(ctx context.Context, attachment *models.EmailAttachment, emailID, mailboxID string, data []byte) (string, error)
	DownloadAttachment(ctx context.Context, id string) ([]byte, error)
	Delete(ctx context.Context, id string) error
}

type EmailEventRepository added in v0.2.5

type EmailEventRepository interface {
	Create(ctx context.Context, emailEvent *models.EmailEvent) error
}

type EmailLogRepository added in v0.2.5

type EmailLogRepository interface {
	Create(ctx context.Context, emailLog *models.EmailLog) error
	IsDuplicateByHash(ctx context.Context, emailHash string) (bool, error)
	UpdateEmailLog(ctx context.Context, id string, updates map[string]interface{}) error
}

type EmailProcessor added in v0.1.12

type EmailProcessor interface {
	Start(ctx context.Context) error
	Close() error
}

type EmailRepository

type EmailRepository interface {
	Create(ctx context.Context, email *models.Email) (string, error)
	GetByID(ctx context.Context, id string) (*models.Email, error)
	GetByUID(ctx context.Context, mailboxID, folder string, uid uint32) (*models.Email, error)
	GetByMessageID(ctx context.Context, messageID string) (*models.Email, error)
	ListByMailbox(ctx context.Context, mailboxID string, limit, offset int) ([]*models.Email, int64, error)
	ListByFolder(ctx context.Context, mailboxID, folder string, limit, offset int) ([]*models.Email, int64, error)
	ListByThread(ctx context.Context, threadID string) ([]*models.Email, error)
	Search(ctx context.Context, query string, limit, offset int) ([]*models.Email, int64, error)
	Update(ctx context.Context, email *models.Email) error
	SetEmailRawData(ctx context.Context, emailID string, headers, envelope, bodyStructure models.JSONMap) error
}

type EmailService

type EmailService interface {
	ScheduleSend(ctx context.Context, email *models.EmailLog, attachmentIDs []string) (string, enum.EmailStatus, error)

	// used only by events
	SendWithSMTP(ctx context.Context, mailbox *models.Mailbox, email *models.EmailLog, attachments []*models.EmailAttachment) error
}

type EmailThreadRepository added in v0.0.3

type EmailThreadRepository interface {
	Create(ctx context.Context, thread *models.EmailThread) (string, error)
	GetByID(ctx context.Context, id string) (*models.EmailThread, error)
	GetByMailboxIDs(ctx context.Context, mailboxIDs []string, limit int, offset int) ([]*models.EmailThread, error)
	CountByMailboxIDs(ctx context.Context, mailboxIDs []string) (int64, error)
	Update(ctx context.Context, thread *models.EmailThread) error
	GetParticipantsForThread(ctx context.Context, threadID string) ([]string, error)
	FindBySubjectAndMailbox(ctx context.Context, subject string, mailboxID string) ([]*models.EmailThread, error)
	MarkThreadAsViewed(ctx context.Context, threadID string) error
	MarkThreadAsDone(ctx context.Context, threadID string, isDone bool) error
}

type FolderStats

type FolderStats struct {
	Total    uint32
	Unseen   uint32
	LastSeen uint32
	LastSync time.Time
}

type GoogleService added in v0.2.16

type GoogleService interface {
	// RefreshTokenIfNeeded checks if the token needs refresh and refreshes it if necessary
	RefreshTokenIfNeeded(ctx context.Context, mailbox *models.Mailbox) error

	// RefreshToken refreshes the OAuth2 token for the given mailbox
	RefreshToken(ctx context.Context, mailbox *models.Mailbox) error

	// GetDecryptedAccessToken returns the decrypted access token for the mailbox
	GetDecryptedAccessToken(ctx context.Context, mailbox *models.Mailbox) (string, error)
}

GoogleService handles Google-specific operations like OAuth2 token management

type IMAPService

type IMAPService interface {
	Start(ctx context.Context) error
	Stop() error
	GetMessageByUID(ctx context.Context, mailboxID, folderName string, uid uint32) (*imap.Message, error)
	Status() map[string]MailboxStatus
	AcceptMailboxForSync(ctx context.Context, mailbox *models.Mailbox) bool
	ListFolders(ctx context.Context, mailboxID string) ([]string, error)
}

type MailEvent

type MailEvent struct {
	Source    string
	MailboxID string
	Folder    string
	MessageID uint32
	EventType string
	Message   interface{}
}

type MailboxDetails added in v0.0.3

type MailboxDetails struct {
	Email             string   `json:"email"`
	ForwardingEnabled bool     `json:"forwardingEnabled"`
	ForwardingTo      []string `json:"forwardingTo"`
	WebmailEnabled    bool     `json:"webmailEnabled"`
}

type MailboxRepository

type MailboxRepository interface {
	GetMailboxes(ctx context.Context) ([]*models.Mailbox, error)
	GetMailboxesByUserID(ctx context.Context, userID string) ([]*models.Mailbox, error)
	GetMailbox(ctx context.Context, id string) (*models.Mailbox, error)
	GetMailboxByEmailAddress(ctx context.Context, emailAddress string) (*models.Mailbox, error)
	GetMailboxByEmailAddressCrossTenant(ctx context.Context, emailAddress string) (*models.Mailbox, error)
	GetForConfiguration(ctx context.Context, limit int) ([]*models.Mailbox, error)
	GetAllWithFilters(ctx context.Context, provider enum.EmailProvider, domain, userId string) ([]*models.Mailbox, error)
	SaveMailbox(ctx context.Context, mailbox models.Mailbox) (string, error)
	DeleteMailbox(ctx context.Context, id string) error
	UpdateConnectionStatus(ctx context.Context, mailboxID string, status enum.ConnectionStatus, errorMessage string) error

	UpdateProvisionStatus(ctx context.Context, id string, status models.MailboxProvisionStatus) error
	ConfigureAttempt(ctx context.Context, id string) error
	GetForRampUp(ctx context.Context) ([]*models.Mailbox, error)
	UpdateRampUpFields(ctx context.Context, mailbox *models.Mailbox) error
	UpdateOauthToken(ctx context.Context, mailboxID, accessToken, refreshToken string, tokenExpiry *time.Time) error
	MarkForManualRefresh(ctx context.Context, mailboxID string, needsManualRefresh bool) error

	// Methods for distributed processing
	GetMailboxesForSync(ctx context.Context, staleTimeout time.Duration) ([]*models.Mailbox, error)
	AcquireMailboxLock(ctx context.Context, mailboxID, podID string, staleTimeout time.Duration) (bool, error)
	UpdateMailboxHeartbeat(ctx context.Context, mailboxID, podID string) error
	ReleaseMailboxLock(ctx context.Context, mailboxID, podID string) error
}

type MailboxService added in v0.0.3

type MailboxService interface {
	EnrollMailbox(ctx context.Context, mailbox *models.Mailbox) (*models.Mailbox, error)
	CreateMailbox(ctx context.Context, request CreateMailboxRequest) error
	ConfigureMailbox(ctx context.Context, mailboxId string) error
	RampUpMailboxes(ctx context.Context) error
	GetMailboxes(ctx context.Context, provider enum.EmailProvider, domain, userId string) ([]*models.Mailbox, error)
	GetMailboxByEmailAddress(ctx context.Context, emailAddress string) (*models.Mailbox, error)
}

type MailboxServiceOld added in v0.1.3

type MailboxServiceOld interface {
	IsDomainAvailable(ctx context.Context, domain string) (ok, available bool)
	RecommendOutboundDomains(ctx context.Context, domainRoot string, count int) []string
	ReputationScore(ctx context.Context, domain, tenant string) (int, error)
}

type MailboxStatus

type MailboxStatus struct {
	Connected   bool
	LastError   string
	Folders     map[string]FolderStats
	LastChecked time.Time
}

type MailboxSyncRepository

type MailboxSyncRepository interface {
	GetSyncState(ctx context.Context, mailboxID, folderName string) (*models.MailboxSyncState, error)
	SaveSyncState(ctx context.Context, state *models.MailboxSyncState) error
	DeleteSyncState(ctx context.Context, mailboxID, folderName string) error
	DeleteMailboxSyncStates(ctx context.Context, mailboxID string) error
	GetAllSyncStates(ctx context.Context) (map[string]map[string]uint32, error)
	GetMailboxSyncStates(ctx context.Context, mailboxID string) (map[string]uint32, error)
}

type NamecheapDomainInfo added in v0.0.3

type NamecheapDomainInfo struct {
	DomainName  string   `json:"domainName"`
	CreatedDate string   `json:"createdDate"`
	ExpiredDate string   `json:"expiredDate"`
	Nameservers []string `json:"nameservers"`
	WhoisGuard  bool     `json:"whoisGuard"`
}

type NamecheapService added in v0.0.3

type NamecheapService interface {
	CheckDomainAvailability(ctx context.Context, domain string) (bool, bool, error)
	PurchaseDomain(ctx context.Context, tenant, domain string) error
	GetDomainPrice(ctx context.Context, domain string) (float64, error)
	GetDomainInfo(ctx context.Context, tenant, domain string) (NamecheapDomainInfo, error)
	UpdateNameservers(ctx context.Context, tenant, domain string, nameservers []string) error
}

type OauthMailboxRequest added in v0.2.16

type OauthMailboxRequest struct {
	OAuthRefreshToken string
	OAuthAccessToken  string
	OAuthTokenExpiry  *time.Time
	OAuthScope        string
	OAuthTokenId      string
}

type OpenSrsService added in v0.0.3

type OpenSrsService interface {
	SendEmail(ctx context.Context, request *models.EmailMessage) error
	SetupDomain(ctx context.Context, tenant, domain string) error
	SetupMailbox(ctx context.Context, tenant, username, password string, forwardingTo []string, webmailEnabled bool) error
	GetMailboxDetails(ctx context.Context, email string) (MailboxDetails, error)
}

type OrphanEmailRepository added in v0.0.3

type OrphanEmailRepository interface {
	Create(ctx context.Context, orphan *models.OrphanEmail) (string, error)
	GetByID(ctx context.Context, id string) (*models.OrphanEmail, error)
	GetByMessageID(ctx context.Context, messageID string) (*models.OrphanEmail, error)
	Delete(ctx context.Context, id string) error
	DeleteByThreadID(ctx context.Context, threadID string) error
	ListByThreadID(ctx context.Context, threadID string) ([]*models.OrphanEmail, error)
	ListByMailboxID(ctx context.Context, mailboxID string, limit, offset int) ([]*models.OrphanEmail, error)
	DeleteOlderThan(ctx context.Context, cutoffDate time.Time) error
}

type SenderRepository added in v0.0.22

type SenderRepository interface {
	Create(ctx context.Context, sender *models.Sender) error
	GetByID(ctx context.Context, id string) (*models.Sender, error)
	GetByUserID(ctx context.Context, userID string) ([]models.Sender, error)
	GetDefaultForUser(ctx context.Context, userID string) (*models.Sender, error)
	Update(ctx context.Context, sender *models.Sender) error
	SetDefault(ctx context.Context, id string, userID string) error
	SetActive(ctx context.Context, id string, isActive bool) error
	Delete(ctx context.Context, id string) error
	ListByTenant(ctx context.Context, tenant string, limit, offset int) ([]models.Sender, int64, error)
}

type StorageService

type StorageService interface {
	Upload(ctx context.Context, key string, data []byte, contentType string) error
	Download(ctx context.Context, key string) ([]byte, error)
	Delete(ctx context.Context, key string) error
	GetPublicURL(key string) string
}

Jump to

Keyboard shortcuts

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