notify

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager manages multiple notifiers

func NewManager

func NewManager() *Manager

NewManager creates a new notification manager

func (*Manager) Broadcast

func (m *Manager) Broadcast(ctx context.Context, notification *Notification) error

Broadcast sends notification through all registered notifiers

func (*Manager) Register

func (m *Manager) Register(n Notifier)

Register adds a notifier

func (*Manager) Send

func (m *Manager) Send(ctx context.Context, notification *Notification) error

Send sends through the first available notifier

func (*Manager) SendViaType

func (m *Manager) SendViaType(ctx context.Context, notifierType string, notification *Notification) error

SendViaType sends through a specific notifier type

type Notification

type Notification struct {
	Type     string      `json:"type"` // reminder, suggestion, alert
	Title    string      `json:"title"`
	Message  string      `json:"message"`
	Data     interface{} `json:"data,omitempty"`
	Priority string      `json:"priority,omitempty"` // low, normal, high
}

Notification represents a notification to send

type Notifier

type Notifier interface {
	// Send sends a notification
	Send(ctx context.Context, notification *Notification) error

	// SendToUser sends to a specific user/client
	SendToUser(ctx context.Context, userID string, notification *Notification) error

	// Broadcast sends to all connected clients
	Broadcast(ctx context.Context, notification *Notification) error

	// Type returns the notifier type (websocket, push, etc.)
	Type() string
}

Notifier is the interface for sending notifications

type PushNotifier

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

PushNotifier handles push notifications (placeholder for future implementation) This would integrate with services like Firebase Cloud Messaging, Apple Push Notification Service, etc.

func NewPushNotifier

func NewPushNotifier() *PushNotifier

NewPushNotifier creates a new push notifier

func (*PushNotifier) Broadcast

func (n *PushNotifier) Broadcast(ctx context.Context, notification *Notification) error

Broadcast sends to all registered devices

func (*PushNotifier) RegisterDevice

func (n *PushNotifier) RegisterDevice(ctx context.Context, userID, deviceToken, platform string) error

RegisterDevice registers a device token for push notifications

func (*PushNotifier) Send

func (n *PushNotifier) Send(ctx context.Context, notification *Notification) error

Send sends a push notification

func (*PushNotifier) SendToUser

func (n *PushNotifier) SendToUser(ctx context.Context, userID string, notification *Notification) error

SendToUser sends to a specific user's device(s)

func (*PushNotifier) Type

func (n *PushNotifier) Type() string

Type returns the notifier type

func (*PushNotifier) UnregisterDevice

func (n *PushNotifier) UnregisterDevice(ctx context.Context, deviceToken string) error

UnregisterDevice removes a device token

type WebSocketNotifier

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

WebSocketNotifier sends notifications via WebSocket

func NewWebSocketNotifier

func NewWebSocketNotifier(hub *ws.Hub) *WebSocketNotifier

NewWebSocketNotifier creates a WebSocket notifier

func (*WebSocketNotifier) Broadcast

func (n *WebSocketNotifier) Broadcast(ctx context.Context, notification *Notification) error

Broadcast sends to all connected WebSocket clients

func (*WebSocketNotifier) Send

func (n *WebSocketNotifier) Send(ctx context.Context, notification *Notification) error

Send sends a notification (broadcasts since we don't have user tracking)

func (*WebSocketNotifier) SendToUser

func (n *WebSocketNotifier) SendToUser(ctx context.Context, userID string, notification *Notification) error

SendToUser sends to a specific user (not implemented for basic WebSocket)

func (*WebSocketNotifier) Type

func (n *WebSocketNotifier) Type() string

Type returns the notifier type

Jump to

Keyboard shortcuts

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