package notifications import ( "context" "galo/internal/auth" "galo/internal/httpx" "galo/internal/models" "galo/internal/sse" ) type Service struct { store Repository hub *sse.Hub } func NewService(store Repository, hub *sse.Hub) *Service { return &Service{store: store, hub: hub} } func (s *Service) Create(ctx context.Context, userID, typ string, payload map[string]any) error { n := &models.Notification{ ID: auth.NewID(), UserID: userID, Type: typ, PayloadJSON: payload, } if err := s.store.Create(ctx, n); err != nil { return err } s.hub.PublishUser(userID, "notification", n) return nil } func (s *Service) List(ctx context.Context, userID string, limit int) ([]models.Notification, error) { return s.store.List(ctx, userID, limit) } func (s *Service) MarkRead(ctx context.Context, id, userID string) error { if err := s.store.MarkRead(ctx, id, userID); err != nil { return httpx.NotFound("notification_not_found", "notification not found") } return nil }