notification

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPending NotificationStatus = "PENDING"
	StatusSent    NotificationStatus = "SENT"
	StatusFailed  NotificationStatus = "FAILED"

	ChannelEmail NotificationChannel = "EMAIL"
	ChannelSMS   NotificationChannel = "SMS"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MockProvider

type MockProvider struct {
	ShouldFail bool
}

MockProvider is a simple provider for testing and development.

func (*MockProvider) Send

func (m *MockProvider) Send(ctx context.Context, n *Notification) error

type Module

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

Module implements the mdk.Module interface for Notification.

func NewModule

func NewModule(provider Provider) *Module

func (*Module) FieldResolvers

func (m *Module) FieldResolvers() map[string]any

func (*Module) ID

func (m *Module) ID() string

func (*Module) Init

func (m *Module) Init(ctx context.Context, rt mdk.Runtime) error

func (*Module) ListNotifications

func (m *Module) ListNotifications(ctx context.Context, recipient *string) ([]*Notification, error)

func (*Module) Models

func (m *Module) Models() []any

func (*Module) Mutations

func (m *Module) Mutations() map[string]any

func (*Module) Queries

func (m *Module) Queries() map[string]any

func (*Module) Repo

func (m *Module) Repo() *Repository

func (*Module) Routes

func (m *Module) Routes() []mdk.Route

func (*Module) SendNotification

func (m *Module) SendNotification(ctx context.Context, input any) (any, error)

SendNotification executes the notification delivery via the provider.

func (*Module) SendNotificationStep

func (m *Module) SendNotificationStep(sCtx mdk.StepContext) mdk.StepResult

SendNotificationStep wraps SendNotification to mdk.StepHandler.

func (*Module) Shutdown

func (m *Module) Shutdown(ctx context.Context) error

type Notification

type Notification struct {
	ID        string              `gorm:"primaryKey" json:"id"`
	Recipient string              `gorm:"index;not null" json:"recipient"`
	Channel   NotificationChannel `gorm:"not null" json:"channel"`
	Subject   string              `json:"subject"`
	Body      string              `json:"body"`
	Status    NotificationStatus  `gorm:"not null" json:"status"`
	CreatedAt time.Time           `json:"created_at"`
	UpdatedAt time.Time           `json:"updated_at"`
	DeletedAt gorm.DeletedAt      `gorm:"index" json:"-"`
}

Notification represents a message sent to a user.

type NotificationChannel

type NotificationChannel string

type NotificationStatus

type NotificationStatus string

type Provider

type Provider interface {
	Send(ctx context.Context, n *Notification) error
}

Provider defines the interface for sending notifications.

type Repository

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

Repository handles data access for notifications.

func NewRepository

func NewRepository(database *gorm.DB) *Repository

NewRepository creates a new Repository.

func (*Repository) GetByID

func (r *Repository) GetByID(ctx context.Context, id string) (*Notification, error)

GetByID retrieves a notification by its ID.

func (*Repository) List

func (r *Repository) List(ctx context.Context, recipient string) ([]*Notification, error)

List retrieves all notifications, optionally filtered by recipient.

func (*Repository) Save

func (r *Repository) Save(ctx context.Context, n *Notification) error

Save persists a notification to the database.

Jump to

Keyboard shortcuts

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