notification

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound         = errors.New("notification not found")
	ErrPermissionDenied = errors.New("permission denied to access this notification")
	ErrInvalidArgument  = errors.New("invalid argument provided")
)

Error definitions for the notification service layer.

Functions

This section is empty.

Types

type Config

type Config struct {
	NotificationRepo repository.NotificationRepository
	UserRepo         repository.UserRepository
	Logger           *slog.Logger
}

Config holds the configuration and dependencies for the notification service.

type Service

type Service interface {
	// List retrieves a paginated list of notifications for a specific user.
	List(ctx context.Context, userID uuid.UUID, page, pageSize int) ([]model.Notification, int, error)

	// MarkAsRead marks a single notification as read. It ensures the notification belongs to the user.
	MarkAsRead(ctx context.Context, userID, notificationID uuid.UUID) error

	// MarkAllAsRead marks all unread notifications for a user as read.
	MarkAllAsRead(ctx context.Context, userID uuid.UUID) error

	// GetSettings retrieves the notification settings for a user. If no settings exist, it creates and returns default settings.
	GetSettings(ctx context.Context, userID uuid.UUID) (*model.NotificationSettings, error)

	// UpdateSettings updates the notification settings for a user based on the provided request.
	UpdateSettings(ctx context.Context, userID uuid.UUID, req *model.UpdateNotificationSettingsRequest) (*model.NotificationSettings, error)

	// Create creates a new notification. This method is typically called by other services within the application
	// (e.g., when a user gets a new follower or a comment on their post).
	Create(ctx context.Context, notification *model.Notification) error
}

Service defines the interface for notification-related business logic. It abstracts the underlying data storage and provides a clean API for notification operations.

func NewService

func NewService(cfg Config) (Service, error)

NewService creates and returns a new notification service instance. It validates that all necessary dependencies are provided.

Jump to

Keyboard shortcuts

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