Documentation
¶
Index ¶
- func GetBaseDir() string
- type DeleteSubscriptionRequest
- type HistoryResponse
- type JSONLStorage
- func (s *JSONLStorage) AddNotificationHistory(userID string, notification NotificationHistory) error
- func (s *JSONLStorage) AddSubscription(userID string, sub Subscription) error
- func (s *JSONLStorage) DeleteSubscription(userID string, endpoint string) error
- func (s *JSONLStorage) GetAllSubscriptions() ([]Subscription, error)
- func (s *JSONLStorage) GetNotificationHistory(userID string, limit, offset int, filters map[string]string) ([]NotificationHistory, int, error)
- func (s *JSONLStorage) GetSubscriptions(userID string) ([]Subscription, error)
- func (s *JSONLStorage) RotateNotificationHistory(userID string, maxEntries int) error
- func (s *JSONLStorage) UpdateSubscription(userID string, subscriptionID string, updates Subscription) error
- type NotificationHistory
- type Service
- func (s *Service) DeleteSubscription(userID string, endpoint string) error
- func (s *Service) GetNotificationHistory(userID string, limit, offset int, filters map[string]string) (*HistoryResponse, error)
- func (s *Service) GetSubscriptions(userID string) ([]Subscription, error)
- func (s *Service) ProcessWebhook(webhook WebhookRequest) error
- func (s *Service) SendNotificationToSession(sessionID string, title, body, notificationType string, ...) error
- func (s *Service) SendNotificationToUser(userID string, title, body, notificationType string, ...) error
- func (s *Service) Subscribe(user *auth.UserContext, endpoint string, keys map[string]string) (*Subscription, error)
- type Storage
- type SubscribeRequest
- type SubscribeResponse
- type Subscription
- type WebPushService
- type WebhookRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DeleteSubscriptionRequest ¶
type DeleteSubscriptionRequest struct {
Endpoint string `json:"endpoint" validate:"required"`
}
DeleteSubscriptionRequest represents the request body for deleting a subscription
type HistoryResponse ¶
type HistoryResponse struct {
Notifications []NotificationHistory `json:"notifications"`
Total int `json:"total"`
HasMore bool `json:"has_more"`
}
HistoryResponse represents the response for notification history endpoint
type JSONLStorage ¶
type JSONLStorage struct {
// contains filtered or unexported fields
}
JSONLStorage implements Storage using JSONL files
func NewJSONLStorage ¶
func NewJSONLStorage(baseDir string) *JSONLStorage
NewJSONLStorage creates a new JSONL-based storage
func (*JSONLStorage) AddNotificationHistory ¶
func (s *JSONLStorage) AddNotificationHistory(userID string, notification NotificationHistory) error
AddNotificationHistory adds a notification to the history
func (*JSONLStorage) AddSubscription ¶
func (s *JSONLStorage) AddSubscription(userID string, sub Subscription) error
AddSubscription adds a new subscription for a user
func (*JSONLStorage) DeleteSubscription ¶
func (s *JSONLStorage) DeleteSubscription(userID string, endpoint string) error
DeleteSubscription marks a subscription as inactive
func (*JSONLStorage) GetAllSubscriptions ¶
func (s *JSONLStorage) GetAllSubscriptions() ([]Subscription, error)
GetAllSubscriptions returns all active subscriptions from all users
func (*JSONLStorage) GetNotificationHistory ¶
func (s *JSONLStorage) GetNotificationHistory(userID string, limit, offset int, filters map[string]string) ([]NotificationHistory, int, error)
GetNotificationHistory retrieves notification history with pagination and filtering
func (*JSONLStorage) GetSubscriptions ¶
func (s *JSONLStorage) GetSubscriptions(userID string) ([]Subscription, error)
GetSubscriptions returns all active subscriptions for a user
func (*JSONLStorage) RotateNotificationHistory ¶
func (s *JSONLStorage) RotateNotificationHistory(userID string, maxEntries int) error
RotateNotificationHistory keeps only the most recent N entries
func (*JSONLStorage) UpdateSubscription ¶
func (s *JSONLStorage) UpdateSubscription(userID string, subscriptionID string, updates Subscription) error
UpdateSubscription updates an existing subscription
type NotificationHistory ¶
type NotificationHistory struct {
ID string `json:"id"`
UserID string `json:"user_id"`
SubscriptionID string `json:"subscription_id"`
Title string `json:"title"`
Body string `json:"body"`
Type string `json:"type"`
SessionID string `json:"session_id"`
Data map[string]interface{} `json:"data"`
SentAt time.Time `json:"sent_at"`
Delivered bool `json:"delivered"`
Clicked bool `json:"clicked"`
ErrorMessage *string `json:"error_message"`
}
NotificationHistory represents a notification that was sent
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides notification functionality
func NewService ¶
NewService creates a new notification service
func (*Service) DeleteSubscription ¶
DeleteSubscription removes a subscription by endpoint
func (*Service) GetNotificationHistory ¶
func (s *Service) GetNotificationHistory(userID string, limit, offset int, filters map[string]string) (*HistoryResponse, error)
GetNotificationHistory retrieves notification history for a user
func (*Service) GetSubscriptions ¶
func (s *Service) GetSubscriptions(userID string) ([]Subscription, error)
GetSubscriptions returns all active subscriptions for a user
func (*Service) ProcessWebhook ¶
func (s *Service) ProcessWebhook(webhook WebhookRequest) error
ProcessWebhook handles incoming webhooks from agentapi
func (*Service) SendNotificationToSession ¶
func (s *Service) SendNotificationToSession(sessionID string, title, body, notificationType string, data map[string]interface{}) error
SendNotificationToSession sends a notification to all users subscribed to a session
func (*Service) SendNotificationToUser ¶
func (s *Service) SendNotificationToUser(userID string, title, body, notificationType string, data map[string]interface{}) error
SendNotificationToUser sends a notification to all subscriptions of a user
func (*Service) Subscribe ¶
func (s *Service) Subscribe(user *auth.UserContext, endpoint string, keys map[string]string) (*Subscription, error)
Subscribe creates a new push notification subscription
type Storage ¶
type Storage interface {
// Subscription methods
AddSubscription(userID string, sub Subscription) error
GetSubscriptions(userID string) ([]Subscription, error)
GetAllSubscriptions() ([]Subscription, error)
UpdateSubscription(userID string, subscriptionID string, updates Subscription) error
DeleteSubscription(userID string, endpoint string) error
// History methods
AddNotificationHistory(userID string, notification NotificationHistory) error
GetNotificationHistory(userID string, limit, offset int, filters map[string]string) ([]NotificationHistory, int, error)
RotateNotificationHistory(userID string, maxEntries int) error
}
Storage interface for notification data persistence
type SubscribeRequest ¶
type SubscribeRequest struct {
Endpoint string `json:"endpoint" validate:"required"`
Keys map[string]string `json:"keys" validate:"required"`
}
SubscribeRequest represents the request body for subscribing to push notifications
type SubscribeResponse ¶
type SubscribeResponse struct {
Success bool `json:"success"`
SubscriptionID string `json:"subscription_id"`
}
SubscribeResponse represents the response for a successful subscription
type Subscription ¶
type Subscription struct {
ID string `json:"id"`
UserID string `json:"user_id"`
UserType string `json:"user_type"`
Username string `json:"username"`
Endpoint string `json:"endpoint"`
Keys map[string]string `json:"keys"`
SessionIDs []string `json:"session_ids"`
NotificationTypes []string `json:"notification_types"`
CreatedAt time.Time `json:"created_at"`
Active bool `json:"active"`
}
Subscription represents a push notification subscription in the system
type WebPushService ¶
type WebPushService struct {
// contains filtered or unexported fields
}
WebPushService handles sending web push notifications
func NewWebPushService ¶
func NewWebPushService() (*WebPushService, error)
NewWebPushService creates a new web push service
func (*WebPushService) SendNotification ¶
func (s *WebPushService) SendNotification(sub Subscription, title, body string, data map[string]interface{}) error
SendNotification sends a push notification to a subscription
func (*WebPushService) SendNotificationWithOptions ¶
func (s *WebPushService) SendNotificationWithOptions(sub Subscription, title, body string, data map[string]interface{}, ttl int, urgency string) error
SendNotificationWithOptions sends a push notification with custom options