Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
NewService creates and returns a new notification service instance. It validates that all necessary dependencies are provided.