inbox

package
v0.8.0-beta Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package inbox provides functionality to manage inboxes in the system.

Index

Constants

View Source
const (
	ChannelEmail = "email"
)

Variables

View Source
var (

	// ErrInboxNotFound is returned when an inbox is not found.
	ErrInboxNotFound = errors.New("inbox not found")
)

Functions

This section is empty.

Types

type Closer

type Closer interface {
	Close() error
}

Closer provides a function for closing an inbox.

type Identifier

type Identifier interface {
	Identifier() int
}

Identifier provides a method for obtaining a unique identifier for the inbox.

type Inbox

type Inbox interface {
	Closer
	Identifier
	MessageHandler
	FromAddress() string
	Channel() string
}

Inbox combines the operations of an inbox including its lifecycle, identification, and message handling.

type Manager

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

func New

func New(lo *logf.Logger, db *sqlx.DB, i18n *i18n.I18n) (*Manager, error)

New returns a new inbox manager.

func (*Manager) Close

func (m *Manager) Close()

Close closes all inboxes.

func (*Manager) Create

func (m *Manager) Create(inbox imodels.Inbox) (imodels.Inbox, error)

Create creates an inbox in the DB.

func (*Manager) Get

func (m *Manager) Get(id int) (Inbox, error)

Get retrieves the initialized inbox instance with the specified ID from memory.

func (*Manager) GetAll

func (m *Manager) GetAll() ([]imodels.Inbox, error)

GetAll returns all inboxes from the DB.

func (*Manager) GetDBRecord

func (m *Manager) GetDBRecord(id int) (imodels.Inbox, error)

GetDBRecord returns the inbox record from the DB.

func (*Manager) InitInboxes

func (m *Manager) InitInboxes(initFn initFn) error

InitInboxes initializes and registers active inboxes with the manager.

func (*Manager) Register

func (m *Manager) Register(i Inbox)

Register registers the inbox with the manager.

func (*Manager) Reload

func (m *Manager) Reload(ctx context.Context, initFn initFn) error

Reload hot reloads the inboxes with the given init function.

func (*Manager) SetMessageStore

func (m *Manager) SetMessageStore(store MessageStore)

SetMessageStore sets the message store for the manager.

func (*Manager) SetUserStore

func (m *Manager) SetUserStore(store UserStore)

SetUserStore sets the user store for the manager.

func (*Manager) SoftDelete

func (m *Manager) SoftDelete(id int) error

SoftDelete soft deletes an inbox in the DB.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

Start starts the receiver for each inbox.

func (*Manager) Toggle

func (m *Manager) Toggle(id int) (imodels.Inbox, error)

Toggle toggles the status of an inbox in the DB.

func (*Manager) Update

func (m *Manager) Update(id int, inbox imodels.Inbox) (imodels.Inbox, error)

Update updates an inbox in the DB.

type MessageHandler

type MessageHandler interface {
	Receive(context.Context) error
	Send(models.Message) error
}

MessageHandler defines methods for handling message operations.

type MessageStore

type MessageStore interface {
	MessageExists(string) (bool, error)
	EnqueueIncoming(models.IncomingMessage) error
}

MessageStore defines methods for storing and processing messages.

type Opts

type Opts struct {
	QueueSize   int
	Concurrency int
}

Opts contains the options for initializing the inbox manager.

type UserStore

type UserStore interface {
	GetContact(id int, email string) (umodels.User, error)
}

UserStore defines methods for fetching user information.

Directories

Path Synopsis
channel
email
Package email provides functionality for an email inbox with multiple SMTP servers and IMAP clients.
Package email provides functionality for an email inbox with multiple SMTP servers and IMAP clients.

Jump to

Keyboard shortcuts

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