repository

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSenderNotFound      = errors.New("sender not found")
	ErrEmailNotFound       = errors.New("email not found")
	ErrSenderAlreadyExists = errors.New("sender already exists")
	ErrInvalidInput        = errors.New("invalid input parameters")
)

Functions

func MigrateMailstackDB added in v0.0.15

func MigrateMailstackDB(dbConfig *config.MailstackDatabaseConfig, mailstackDB *gorm.DB) error

func MigrateOpenlineDB added in v0.0.15

func MigrateOpenlineDB(dbConfig *config.OpenlineDatabaseConfig, openlineDB *gorm.DB) error

func NewEmailAttachmentRepository

func NewEmailAttachmentRepository(db *gorm.DB, storageService interfaces.StorageService) interfaces.EmailAttachmentRepository

func NewEmailRepository

func NewEmailRepository(db *gorm.DB) interfaces.EmailRepository

func NewEmailStore added in v0.1.13

func NewEmailStore(ch *ch.DB) interfaces.EmailStore

func NewEmailThreadRepository added in v0.0.3

func NewEmailThreadRepository(db *gorm.DB) interfaces.EmailThreadRepository

NewEmailThreadRepository creates a new email thread repository

func NewMailboxRepository

func NewMailboxRepository(db *gorm.DB) interfaces.MailboxRepository

func NewMailboxSyncRepository

func NewMailboxSyncRepository(db *gorm.DB) interfaces.MailboxSyncRepository

func NewOrphanEmailRepository added in v0.0.3

func NewOrphanEmailRepository(db *gorm.DB) interfaces.OrphanEmailRepository

NewOrphanEmailRepository creates a new orphan email repository

Types

type DomainRepository added in v0.0.3

type DomainRepository interface {
	RegisterDomain(ctx context.Context, tenant, domain string) (*models.MailStackDomain, error)
	CheckDomainOwnership(ctx context.Context, tenant, domain string) (bool, error)
	GetDomain(ctx context.Context, tenant, domain string) (*models.MailStackDomain, error)
	GetActiveDomains(ctx context.Context, tenant string) ([]models.MailStackDomain, error)
	MarkConfigured(ctx context.Context, tenant, domain string) error
	SetDkimKeys(ctx context.Context, tenant, domain, dkimPublic, dkimPrivate string) error
	CreateDMARCReport(ctx context.Context, tenant string, report *models.DMARCMonitoring) error
	CreateMailstackReputationScore(ctx context.Context, tenant string, score *models.MailstackReputation) error
	GetDomainCrossTenant(ctx context.Context, domain string) (*models.MailStackDomain, error)
	GetAllActiveDomainsCrossTenant(ctx context.Context) ([]models.MailStackDomain, error)
}

func NewDomainRepository added in v0.0.3

func NewDomainRepository(db *gorm.DB) DomainRepository

type GormSenderRepository added in v0.0.22

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

GormSenderRepository implements SenderRepository using GORM

func (*GormSenderRepository) Create added in v0.0.22

func (r *GormSenderRepository) Create(ctx context.Context, sender *models.Sender) error

Create adds a new sender to the database

func (*GormSenderRepository) Delete added in v0.0.22

func (r *GormSenderRepository) Delete(ctx context.Context, id string) error

Delete removes a sender from the database

func (*GormSenderRepository) GetByID added in v0.0.22

func (r *GormSenderRepository) GetByID(ctx context.Context, id string) (*models.Sender, error)

GetByID retrieves a sender by its ID

func (*GormSenderRepository) GetByUserID added in v0.0.22

func (r *GormSenderRepository) GetByUserID(ctx context.Context, userID string) ([]models.Sender, error)

GetByUserID retrieves all senders for a specific user

func (*GormSenderRepository) GetDefaultForUser added in v0.0.22

func (r *GormSenderRepository) GetDefaultForUser(ctx context.Context, userID string) (*models.Sender, error)

GetDefaultForUser retrieves the default sender for a specific user

func (*GormSenderRepository) ListByTenant added in v0.0.22

func (r *GormSenderRepository) ListByTenant(ctx context.Context, tenant string, limit, offset int) ([]models.Sender, int64, error)

ListByTenant retrieves all senders for a specific tenant with pagination

func (*GormSenderRepository) SetActive added in v0.0.22

func (r *GormSenderRepository) SetActive(ctx context.Context, id string, isActive bool) error

SetActive sets the active status of a sender

func (*GormSenderRepository) SetDefault added in v0.0.22

func (r *GormSenderRepository) SetDefault(ctx context.Context, id string, userID string) error

SetDefault sets a sender as the default for a user

func (*GormSenderRepository) Update added in v0.0.22

func (r *GormSenderRepository) Update(ctx context.Context, sender *models.Sender) error

Update updates an existing sender

type Repositories

type Repositories struct {
	DomainRepository                DomainRepository
	EmailRepository                 interfaces.EmailRepository
	EmailStore                      interfaces.EmailStore
	EmailAttachmentRepository       interfaces.EmailAttachmentRepository
	EmailThreadRepository           interfaces.EmailThreadRepository
	MailboxRepository               interfaces.MailboxRepository
	MailboxSyncRepository           interfaces.MailboxSyncRepository
	OrphanEmailRepository           interfaces.OrphanEmailRepository
	SenderRepository                interfaces.SenderRepository
	TenantSettingsMailboxRepository TenantSettingsMailboxRepository
}

func InitRepositories

func InitRepositories(mailstackDB *gorm.DB, openlineDB *gorm.DB, clickhousDB *ch.DB, r2Config *config.R2StorageConfig) (*Repositories, 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)
}

SenderRepository defines the interface for sender data operations

func NewSenderRepository added in v0.0.22

func NewSenderRepository(db *gorm.DB) SenderRepository

NewSenderRepository creates a new sender repository instance

type TenantSettingsMailboxRepository added in v0.0.3

type TenantSettingsMailboxRepository interface {
	GetForRampUp(ctx context.Context) ([]*models.TenantSettingsMailbox, error)
	GetById(ctx context.Context, id string) (*models.TenantSettingsMailbox, error)
	GetByMailbox(ctx context.Context, mailbox string) (*models.TenantSettingsMailbox, error)
	GetAllWithFilters(ctx context.Context, domain, userId string) ([]*models.TenantSettingsMailbox, error)
	GetForConfiguration(ctx context.Context, limit int) ([]*models.TenantSettingsMailbox, error)

	Create(ctx context.Context, tx *gorm.DB, mailbox *models.TenantSettingsMailbox) error
	Update(ctx context.Context, tx *gorm.DB, mailbox *models.TenantSettingsMailbox) error
	UpdateStatus(ctx context.Context, id string, status models.MailboxStatus) error
	UpdateRampUpFields(ctx context.Context, mailbox *models.TenantSettingsMailbox) error
}

func NewTenantSettingsMailboxRepository added in v0.0.3

func NewTenantSettingsMailboxRepository(db *gorm.DB) TenantSettingsMailboxRepository

Jump to

Keyboard shortcuts

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