Documentation
¶
Index ¶
- Variables
- type AccountAutoSendConfig
- type AccountAutoSendDTO
- type Adapter
- func (a *Adapter) SendAccountDeleted(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
- func (a *Adapter) SendAccountReactivated(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
- func (a *Adapter) SendAccountSuspended(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendAllSessionsRevoked(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
- func (a *Adapter) SendCustom(ctx context.Context, appID xid.ID, templateKey, recipient string, ...) error
- func (a *Adapter) SendDeviceRemoved(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendDirectEmail(ctx context.Context, appID xid.ID, recipient, subject, body string) error
- func (a *Adapter) SendDirectSMS(ctx context.Context, appID xid.ID, recipient, body string) error
- func (a *Adapter) SendEmailChangeRequest(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendEmailChanged(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendEmailOTP(ctx context.Context, appID xid.ID, email, code string, expiryMinutes int) error
- func (a *Adapter) SendMFACode(ctx context.Context, appID xid.ID, recipient, code string, expiryMinutes int, ...) error
- func (a *Adapter) SendMagicLink(ctx context.Context, appID xid.ID, email, userName, magicLink string, ...) error
- func (a *Adapter) SendNewDeviceLogin(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendNewLocationLogin(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendOrgDeleted(ctx context.Context, appID xid.ID, recipientEmail, userName, orgName string) error
- func (a *Adapter) SendOrgInvite(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendOrgMemberAdded(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendOrgMemberLeft(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendOrgMemberRemoved(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendOrgRoleChanged(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendOrgTransfer(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendPasswordChanged(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
- func (a *Adapter) SendPasswordReset(ctx context.Context, appID xid.ID, email, userName, resetURL, resetCode string, ...) error
- func (a *Adapter) SendPhoneOTP(ctx context.Context, appID xid.ID, phone, code string) error
- func (a *Adapter) SendSecurityAlert(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendSuspiciousLogin(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendUsernameChanged(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendVerificationEmail(ctx context.Context, appID xid.ID, ...) error
- func (a *Adapter) SendWelcomeEmail(ctx context.Context, appID xid.ID, email, userName, loginURL string) error
- func (a *Adapter) WithAppName(name string) *Adapter
- func (a *Adapter) WithAppService(appSvc any) *Adapter
- type AnalyticsDTO
- type AsyncAdapter
- func (a *AsyncAdapter) SendAccountDeleted(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
- func (a *AsyncAdapter) SendAccountReactivated(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
- func (a *AsyncAdapter) SendAccountSuspended(ctx context.Context, appID xid.ID, email, userName, reason, timestamp string) error
- func (a *AsyncAdapter) SendAllSessionsRevoked(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
- func (a *AsyncAdapter) SendDeviceRemoved(ctx context.Context, appID xid.ID, ...) error
- func (a *AsyncAdapter) SendEmailChangeRequest(ctx context.Context, appID xid.ID, ...) error
- func (a *AsyncAdapter) SendEmailChanged(ctx context.Context, appID xid.ID, ...) error
- func (a *AsyncAdapter) SendEmailOTP(ctx context.Context, appID xid.ID, email, code string, expiryMinutes int) error
- func (a *AsyncAdapter) SendMFACode(ctx context.Context, appID xid.ID, recipient, code string, expiryMinutes int, ...) error
- func (a *AsyncAdapter) SendMagicLink(ctx context.Context, appID xid.ID, email, userName, magicLink string, ...) error
- func (a *AsyncAdapter) SendNewDeviceLogin(ctx context.Context, appID xid.ID, ...) error
- func (a *AsyncAdapter) SendNewLocationLogin(ctx context.Context, appID xid.ID, ...) error
- func (a *AsyncAdapter) SendOrgInvite(ctx context.Context, appID xid.ID, ...) error
- func (a *AsyncAdapter) SendOrgMemberAdded(ctx context.Context, appID xid.ID, ...) error
- func (a *AsyncAdapter) SendOrgMemberRemoved(ctx context.Context, appID xid.ID, ...) error
- func (a *AsyncAdapter) SendPasswordChanged(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
- func (a *AsyncAdapter) SendPasswordReset(ctx context.Context, appID xid.ID, email, userName, resetURL, resetCode string, ...) error
- func (a *AsyncAdapter) SendPhoneOTP(ctx context.Context, appID xid.ID, phone, code string) error
- func (a *AsyncAdapter) SendSecurityAlert(ctx context.Context, appID xid.ID, ...) error
- func (a *AsyncAdapter) SendSuspiciousLogin(ctx context.Context, appID xid.ID, ...) error
- func (a *AsyncAdapter) SendUsernameChanged(ctx context.Context, appID xid.ID, ...) error
- func (a *AsyncAdapter) SendVerificationEmail(ctx context.Context, appID xid.ID, ...) error
- func (a *AsyncAdapter) SendWelcomeEmail(ctx context.Context, appID xid.ID, email, userName, loginURL string) error
- type AsyncConfig
- type AuthAutoSendConfig
- type AuthAutoSendDTO
- type AutoSendConfig
- type ChannelsResponse
- type Config
- type CreateTemplateInput
- type CreateTemplateResult
- type DailyAnalyticsDTO
- type DashboardExtension
- func (e *DashboardExtension) BridgeFunctions() []ui.BridgeFunction
- func (e *DashboardExtension) DashboardWidgets() []ui.DashboardWidget
- func (e *DashboardExtension) ExtensionID() string
- func (e *DashboardExtension) NavigationItems() []ui.NavigationItem
- func (e *DashboardExtension) RenderDashboardWidget(basePath string, currentApp *app.App) g.Node
- func (e *DashboardExtension) Routes() []ui.Route
- func (e *DashboardExtension) ServeAnalytics(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeEmailBuilder(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeEmailBuilderWithTemplate(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeHistoryList(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeOverview(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeProviders(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeSettings(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeTemplatesList(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) SettingsPages() []ui.SettingsPage
- func (e *DashboardExtension) SettingsSections() []ui.SettingsSection
- type DeclareABTestWinnerRequest
- type DeleteProviderRequest
- type DeleteTemplateInput
- type DeleteTemplateRequest
- type DeleteTemplateResult
- type EmailProviderConfig
- type EmailProviderDTO
- type ErrorResponse
- type GetABTestResultsRequest
- type GetAnalyticsInput
- type GetAnalyticsResult
- type GetNotificationDetailInput
- type GetNotificationDetailResult
- type GetNotificationRequest
- type GetOverviewStatsInput
- type GetOverviewStatsResult
- type GetProviderRequest
- type GetProvidersInput
- type GetProvidersResult
- type GetSettingsInput
- type GetSettingsResult
- type GetTemplateAnalyticsRequest
- type GetTemplateInput
- type GetTemplateRequest
- type GetTemplateResult
- type GetTemplateVersionRequest
- type Handler
- func (h *Handler) CreateABTestVariant(c forge.Context) error
- func (h *Handler) CreateProvider(c forge.Context) error
- func (h *Handler) CreateTemplate(c forge.Context) error
- func (h *Handler) CreateTemplateVersion(c forge.Context) error
- func (h *Handler) DeclareABTestWinner(c forge.Context) error
- func (h *Handler) DeleteProvider(c forge.Context) error
- func (h *Handler) DeleteTemplate(c forge.Context) error
- func (h *Handler) GetABTestResults(c forge.Context) error
- func (h *Handler) GetAppAnalytics(c forge.Context) error
- func (h *Handler) GetNotification(c forge.Context) error
- func (h *Handler) GetOrgAnalytics(c forge.Context) error
- func (h *Handler) GetProvider(c forge.Context) error
- func (h *Handler) GetTemplate(c forge.Context) error
- func (h *Handler) GetTemplateAnalytics(c forge.Context) error
- func (h *Handler) GetTemplateDefaults(c forge.Context) error
- func (h *Handler) GetTemplateVersion(c forge.Context) error
- func (h *Handler) HandleWebhook(c forge.Context) error
- func (h *Handler) ListNotifications(c forge.Context) error
- func (h *Handler) ListProviders(c forge.Context) error
- func (h *Handler) ListTemplateVersions(c forge.Context) error
- func (h *Handler) ListTemplates(c forge.Context) error
- func (h *Handler) PreviewTemplate(c forge.Context) error
- func (h *Handler) RenderTemplate(c forge.Context) error
- func (h *Handler) ResendNotification(c forge.Context) error
- func (h *Handler) ResetAllTemplates(c forge.Context) error
- func (h *Handler) ResetTemplate(c forge.Context) error
- func (h *Handler) RestoreTemplateVersion(c forge.Context) error
- func (h *Handler) SendNotification(c forge.Context) error
- func (h *Handler) TrackNotificationEvent(c forge.Context) error
- func (h *Handler) UpdateProvider(c forge.Context) error
- func (h *Handler) UpdateTemplate(c forge.Context) error
- type ListNotificationsHistoryInput
- type ListNotificationsHistoryResult
- type ListTemplatesInput
- type ListTemplatesResult
- type MailerSendConfig
- type MessageResponse
- type NotificationErrorResponse
- type NotificationHistoryDTO
- type NotificationListResponse
- type NotificationPreviewResponse
- type NotificationResponse
- type NotificationSettingsDTO
- type NotificationStatusResponse
- type NotificationTemplateListResponse
- type NotificationTemplateResponse
- type NotificationWebhookResponse
- type NotificationsResponse
- type OrganizationAutoSendConfig
- type OrganizationAutoSendDTO
- type OverviewStatsDTO
- type PaginationDTO
- type Plugin
- func (p *Plugin) DashboardExtension() ui.DashboardExtension
- func (p *Plugin) GetService() *notification.Service
- func (p *Plugin) GetTemplateService() *TemplateService
- func (p *Plugin) ID() string
- func (p *Plugin) Init(authInst core.Authsome) error
- func (p *Plugin) Migrate() error
- func (p *Plugin) RegisterHooks(hookRegistry *hooks.HookRegistry) error
- func (p *Plugin) RegisterRoutes(router forge.Router) error
- func (p *Plugin) RegisterServiceDecorators(services *registry.ServiceRegistry) error
- func (p *Plugin) Stop()
- type PluginOption
- func WithAddDefaultTemplates(add bool) PluginOption
- func WithAllowAppOverrides(allow bool) PluginOption
- func WithAutoSendWelcome(auto bool) PluginOption
- func WithDefaultConfig(cfg Config) PluginOption
- func WithDefaultLanguage(lang string) PluginOption
- func WithEmailProvider(provider, from, fromName string) PluginOption
- func WithRetryConfig(attempts int, delay time.Duration) PluginOption
- func WithSMSProvider(provider, from string) PluginOption
- type PostmarkConfig
- type PreviewTemplateInput
- type PreviewTemplateRequest
- type PreviewTemplateResult
- type ProvidersConfig
- type ProvidersConfigDTO
- type RateLimit
- type RenderTemplateRequest
- type ResendConfig
- type ResendNotificationRequest
- type ResetTemplateRequest
- type RestoreTemplateVersionRequest
- type SMSProviderConfig
- type SMSProviderDTO
- type SaveBuilderTemplateInput
- type SaveBuilderTemplateResult
- type SendWithTemplateRequest
- type SessionAutoSendConfig
- type SessionAutoSendDTO
- type StatusResponse
- type SuccessResponse
- type TemplateAnalyticsDTO
- type TemplateDTO
- type TemplateDefault
- type TemplateEngine
- type TemplatePerformanceDTO
- type TemplateService
- func (s *TemplateService) RenderTemplate(ctx context.Context, templateID xid.ID, variables map[string]any) (subject, body string, err error)
- func (s *TemplateService) SendDirect(ctx context.Context, appID xid.ID, notifType notification.NotificationType, ...) (*notification.Notification, error)
- func (s *TemplateService) SendEmail(ctx context.Context, appID xid.ID, templateKey, to string, ...) error
- func (s *TemplateService) SendSMS(ctx context.Context, appID xid.ID, templateKey, to string, ...) error
- func (s *TemplateService) SendWithTemplate(ctx context.Context, req *SendWithTemplateRequest) (*notification.Notification, error)
- type TemplatesResponse
- type TestProviderInput
- type TestProviderResult
- type TestSendTemplateInput
- type TestSendTemplateResult
- type UpdateProviderRequest
- type UpdateProvidersInput
- type UpdateProvidersResult
- type UpdateSettingsInput
- type UpdateSettingsResult
- type UpdateTemplateInput
- type UpdateTemplateRequest
- type UpdateTemplateResult
Constants ¶
This section is empty.
Variables ¶
var ( NewResendProvider = providers.NewResendProvider NewMailerSendProvider = providers.NewMailerSendProvider NewPostmarkProvider = providers.NewPostmarkProvider )
Re-export provider constructors.
Functions ¶
This section is empty.
Types ¶
type AccountAutoSendConfig ¶ added in v0.0.6
type AccountAutoSendConfig struct {
EmailChangeRequest bool `json:"email_change_request" yaml:"email_change_request"`
EmailChanged bool `json:"email_changed" yaml:"email_changed"`
PasswordChanged bool `json:"password_changed" yaml:"password_changed"`
UsernameChanged bool `json:"username_changed" yaml:"username_changed"`
Deleted bool `json:"deleted" yaml:"deleted"`
Suspended bool `json:"suspended" yaml:"suspended"`
Reactivated bool `json:"reactivated" yaml:"reactivated"`
}
AccountAutoSendConfig controls account lifecycle notifications.
type AccountAutoSendDTO ¶ added in v0.0.15
type AccountAutoSendDTO struct {
EmailChangeRequest bool `json:"emailChangeRequest"`
EmailChanged bool `json:"emailChanged"`
PasswordChanged bool `json:"passwordChanged"`
UsernameChanged bool `json:"usernameChanged"`
Deleted bool `json:"deleted"`
Suspended bool `json:"suspended"`
Reactivated bool `json:"reactivated"`
}
AccountAutoSendDTO represents account lifecycle notification settings.
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter provides a simplified interface for plugins to send notifications.
func NewAdapter ¶
func NewAdapter(templateSvc *TemplateService) *Adapter
NewAdapter creates a new notification adapter.
func (*Adapter) SendAccountDeleted ¶ added in v0.0.6
func (a *Adapter) SendAccountDeleted(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
SendAccountDeleted sends notification when account is deleted.
func (*Adapter) SendAccountReactivated ¶ added in v0.0.6
func (a *Adapter) SendAccountReactivated(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
SendAccountReactivated sends notification when account is reactivated.
func (*Adapter) SendAccountSuspended ¶ added in v0.0.6
func (a *Adapter) SendAccountSuspended(ctx context.Context, appID xid.ID, recipientEmail, userName, reason, timestamp string) error
SendAccountSuspended sends notification when account is suspended.
func (*Adapter) SendAllSessionsRevoked ¶ added in v0.0.6
func (a *Adapter) SendAllSessionsRevoked(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
SendAllSessionsRevoked sends notification when all sessions are signed out.
func (*Adapter) SendCustom ¶
func (a *Adapter) SendCustom(ctx context.Context, appID xid.ID, templateKey, recipient string, notifType notification.NotificationType, variables map[string]any) error
SendCustom sends a notification using a custom template.
func (*Adapter) SendDeviceRemoved ¶ added in v0.0.6
func (a *Adapter) SendDeviceRemoved(ctx context.Context, appID xid.ID, recipientEmail, userName, deviceName, timestamp string) error
SendDeviceRemoved sends notification when a device is removed from the account.
func (*Adapter) SendDirectEmail ¶
func (a *Adapter) SendDirectEmail(ctx context.Context, appID xid.ID, recipient, subject, body string) error
SendDirectEmail sends an email without using a template.
func (*Adapter) SendDirectSMS ¶
SendDirectSMS sends an SMS without using a template.
func (*Adapter) SendEmailChangeRequest ¶ added in v0.0.6
func (a *Adapter) SendEmailChangeRequest(ctx context.Context, appID xid.ID, recipientEmail, userName, newEmail, confirmationUrl, timestamp string) error
SendEmailChangeRequest sends notification when user requests to change their email.
func (*Adapter) SendEmailChanged ¶ added in v0.0.6
func (a *Adapter) SendEmailChanged(ctx context.Context, appID xid.ID, recipientEmail, userName, oldEmail, timestamp string) error
SendEmailChanged sends notification when email address is successfully changed.
func (*Adapter) SendEmailOTP ¶
func (a *Adapter) SendEmailOTP(ctx context.Context, appID xid.ID, email, code string, expiryMinutes int) error
SendEmailOTP sends an email OTP code.
func (*Adapter) SendMFACode ¶
func (a *Adapter) SendMFACode(ctx context.Context, appID xid.ID, recipient, code string, expiryMinutes int, notifType notification.NotificationType) error
SendMFACode sends an MFA verification code via email or SMS.
func (*Adapter) SendMagicLink ¶
func (a *Adapter) SendMagicLink(ctx context.Context, appID xid.ID, email, userName, magicLink string, expiryMinutes int) error
SendMagicLink sends a magic link email.
func (*Adapter) SendNewDeviceLogin ¶ added in v0.0.6
func (a *Adapter) SendNewDeviceLogin(ctx context.Context, appID xid.ID, recipientEmail, userName, deviceName, location, timestamp, ipAddress string) error
SendNewDeviceLogin sends notification when a user logs in from a new device.
func (*Adapter) SendNewLocationLogin ¶ added in v0.0.6
func (a *Adapter) SendNewLocationLogin(ctx context.Context, appID xid.ID, recipientEmail, userName, location, timestamp, ipAddress string) error
SendNewLocationLogin sends notification when a user logs in from a new location.
func (*Adapter) SendOrgDeleted ¶ added in v0.0.6
func (a *Adapter) SendOrgDeleted(ctx context.Context, appID xid.ID, recipientEmail, userName, orgName string) error
SendOrgDeleted sends notification when an organization is deleted.
func (*Adapter) SendOrgInvite ¶ added in v0.0.6
func (a *Adapter) SendOrgInvite(ctx context.Context, appID xid.ID, recipientEmail, userName, inviterName, orgName, role, inviteURL string, expiresIn string) error
SendOrgInvite sends an organization invitation email.
func (*Adapter) SendOrgMemberAdded ¶ added in v0.0.6
func (a *Adapter) SendOrgMemberAdded(ctx context.Context, appID xid.ID, recipientEmail, userName, memberName, orgName, role string) error
SendOrgMemberAdded sends notification when a member is added to organization.
func (*Adapter) SendOrgMemberLeft ¶ added in v0.0.6
func (a *Adapter) SendOrgMemberLeft(ctx context.Context, appID xid.ID, recipientEmail, userName, memberName, orgName, timestamp string) error
SendOrgMemberLeft sends notification when a member leaves an organization.
func (*Adapter) SendOrgMemberRemoved ¶ added in v0.0.6
func (a *Adapter) SendOrgMemberRemoved(ctx context.Context, appID xid.ID, recipientEmail, userName, memberName, orgName, timestamp string) error
SendOrgMemberRemoved sends notification when a member is removed from organization.
func (*Adapter) SendOrgRoleChanged ¶ added in v0.0.6
func (a *Adapter) SendOrgRoleChanged(ctx context.Context, appID xid.ID, recipientEmail, userName, orgName, oldRole, newRole string) error
SendOrgRoleChanged sends notification when a member's role is changed.
func (*Adapter) SendOrgTransfer ¶ added in v0.0.6
func (a *Adapter) SendOrgTransfer(ctx context.Context, appID xid.ID, recipientEmail, userName, orgName, transferredTo, timestamp string) error
SendOrgTransfer sends notification when organization ownership is transferred.
func (*Adapter) SendPasswordChanged ¶ added in v0.0.6
func (a *Adapter) SendPasswordChanged(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
SendPasswordChanged sends notification when password is changed.
func (*Adapter) SendPasswordReset ¶
func (a *Adapter) SendPasswordReset(ctx context.Context, appID xid.ID, email, userName, resetURL, resetCode string, expiryMinutes int) error
SendPasswordReset sends a password reset email.
func (*Adapter) SendPhoneOTP ¶
SendPhoneOTP sends a phone OTP code via SMS.
func (*Adapter) SendSecurityAlert ¶
func (a *Adapter) SendSecurityAlert(ctx context.Context, appID xid.ID, email, userName, eventType, eventTime, location, device string) error
SendSecurityAlert sends a security alert notification.
func (*Adapter) SendSuspiciousLogin ¶ added in v0.0.6
func (a *Adapter) SendSuspiciousLogin(ctx context.Context, appID xid.ID, recipientEmail, userName, reason, location, timestamp, ipAddress string) error
SendSuspiciousLogin sends notification when suspicious login activity is detected.
func (*Adapter) SendUsernameChanged ¶ added in v0.0.6
func (a *Adapter) SendUsernameChanged(ctx context.Context, appID xid.ID, recipientEmail, userName, oldUsername, newUsername, timestamp string) error
SendUsernameChanged sends notification when username is changed.
func (*Adapter) SendVerificationEmail ¶
func (a *Adapter) SendVerificationEmail(ctx context.Context, appID xid.ID, email, userName, verificationURL, verificationCode string, expiryMinutes int) error
SendVerificationEmail sends an email verification link.
func (*Adapter) SendWelcomeEmail ¶
func (a *Adapter) SendWelcomeEmail(ctx context.Context, appID xid.ID, email, userName, loginURL string) error
SendWelcomeEmail sends a welcome email to new users.
func (*Adapter) WithAppName ¶ added in v0.0.6
WithAppName sets a static app name override.
func (*Adapter) WithAppService ¶ added in v0.0.6
WithAppService sets the app service for dynamic app name lookup.
type AnalyticsDTO ¶ added in v0.0.15
type AnalyticsDTO struct {
Overview OverviewStatsDTO `json:"overview"`
ByTemplate []TemplateAnalyticsDTO `json:"byTemplate"`
ByDay []DailyAnalyticsDTO `json:"byDay"`
TopTemplates []TemplatePerformanceDTO `json:"topTemplates"`
}
AnalyticsDTO represents detailed analytics.
type AsyncAdapter ¶ added in v0.0.7
type AsyncAdapter struct {
*Adapter
// contains filtered or unexported fields
}
AsyncAdapter wraps the standard Adapter to provide async notification sending based on notification priority. Critical notifications are sent synchronously, while non-critical notifications are sent asynchronously to avoid blocking.
func NewAsyncAdapter ¶ added in v0.0.7
func NewAsyncAdapter(adapter *Adapter, config AsyncConfig, dispatcher *notification.Dispatcher, retry *notification.RetryService) *AsyncAdapter
NewAsyncAdapter creates a new async notification adapter.
func (*AsyncAdapter) SendAccountDeleted ¶ added in v0.0.7
func (a *AsyncAdapter) SendAccountDeleted(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
SendAccountDeleted sends an account deleted notification - NORMAL priority (async).
func (*AsyncAdapter) SendAccountReactivated ¶ added in v0.0.7
func (a *AsyncAdapter) SendAccountReactivated(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
SendAccountReactivated sends an account reactivated notification - NORMAL priority (async).
func (*AsyncAdapter) SendAccountSuspended ¶ added in v0.0.7
func (a *AsyncAdapter) SendAccountSuspended(ctx context.Context, appID xid.ID, email, userName, reason, timestamp string) error
SendAccountSuspended sends an account suspended notification - HIGH priority (async with logging).
func (*AsyncAdapter) SendAllSessionsRevoked ¶ added in v0.0.7
func (a *AsyncAdapter) SendAllSessionsRevoked(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
SendAllSessionsRevoked sends all sessions revoked notification - LOW priority (fire-and-forget).
func (*AsyncAdapter) SendDeviceRemoved ¶ added in v0.0.7
func (a *AsyncAdapter) SendDeviceRemoved(ctx context.Context, appID xid.ID, recipientEmail, userName, deviceName, timestamp string) error
SendDeviceRemoved sends a device removed notification - LOW priority (fire-and-forget).
func (*AsyncAdapter) SendEmailChangeRequest ¶ added in v0.0.7
func (a *AsyncAdapter) SendEmailChangeRequest(ctx context.Context, appID xid.ID, recipientEmail, userName, newEmail, confirmationUrl, timestamp string) error
SendEmailChangeRequest sends an email change request notification - HIGH priority (async with logging).
func (*AsyncAdapter) SendEmailChanged ¶ added in v0.0.7
func (a *AsyncAdapter) SendEmailChanged(ctx context.Context, appID xid.ID, recipientEmail, userName, oldEmail, timestamp string) error
SendEmailChanged sends an email changed notification - NORMAL priority (async).
func (*AsyncAdapter) SendEmailOTP ¶ added in v0.0.7
func (a *AsyncAdapter) SendEmailOTP(ctx context.Context, appID xid.ID, email, code string, expiryMinutes int) error
SendEmailOTP sends an email OTP code - CRITICAL priority (sync).
func (*AsyncAdapter) SendMFACode ¶ added in v0.0.7
func (a *AsyncAdapter) SendMFACode(ctx context.Context, appID xid.ID, recipient, code string, expiryMinutes int, notifType notification.NotificationType) error
SendMFACode sends an MFA verification code - CRITICAL priority (sync).
func (*AsyncAdapter) SendMagicLink ¶ added in v0.0.7
func (a *AsyncAdapter) SendMagicLink(ctx context.Context, appID xid.ID, email, userName, magicLink string, expiryMinutes int) error
SendMagicLink sends a magic link email - CRITICAL priority (sync).
func (*AsyncAdapter) SendNewDeviceLogin ¶ added in v0.0.7
func (a *AsyncAdapter) SendNewDeviceLogin(ctx context.Context, appID xid.ID, recipientEmail, userName, deviceName, location, timestamp, ipAddress string) error
SendNewDeviceLogin sends a new device login notification - LOW priority (fire-and-forget).
func (*AsyncAdapter) SendNewLocationLogin ¶ added in v0.0.7
func (a *AsyncAdapter) SendNewLocationLogin(ctx context.Context, appID xid.ID, recipientEmail, userName, location, timestamp, ipAddress string) error
SendNewLocationLogin sends a new location login notification - LOW priority (fire-and-forget).
func (*AsyncAdapter) SendOrgInvite ¶ added in v0.0.7
func (a *AsyncAdapter) SendOrgInvite(ctx context.Context, appID xid.ID, recipientEmail, userName, inviterName, orgName, role, inviteURL, expiresIn string) error
SendOrgInvite sends an organization invite notification - HIGH priority (async with logging).
func (*AsyncAdapter) SendOrgMemberAdded ¶ added in v0.0.7
func (a *AsyncAdapter) SendOrgMemberAdded(ctx context.Context, appID xid.ID, recipientEmail, userName, memberName, orgName, role string) error
SendOrgMemberAdded sends an organization member added notification - NORMAL priority (async).
func (*AsyncAdapter) SendOrgMemberRemoved ¶ added in v0.0.7
func (a *AsyncAdapter) SendOrgMemberRemoved(ctx context.Context, appID xid.ID, recipientEmail, userName, memberName, orgName, timestamp string) error
SendOrgMemberRemoved sends an organization member removed notification - NORMAL priority (async).
func (*AsyncAdapter) SendPasswordChanged ¶ added in v0.0.7
func (a *AsyncAdapter) SendPasswordChanged(ctx context.Context, appID xid.ID, recipientEmail, userName, timestamp string) error
SendPasswordChanged sends a password changed notification - NORMAL priority (async).
func (*AsyncAdapter) SendPasswordReset ¶ added in v0.0.7
func (a *AsyncAdapter) SendPasswordReset(ctx context.Context, appID xid.ID, email, userName, resetURL, resetCode string, expiryMinutes int) error
SendPasswordReset sends a password reset email - CRITICAL priority (sync).
func (*AsyncAdapter) SendPhoneOTP ¶ added in v0.0.7
SendPhoneOTP sends a phone OTP code - CRITICAL priority (sync).
func (*AsyncAdapter) SendSecurityAlert ¶ added in v0.0.7
func (a *AsyncAdapter) SendSecurityAlert(ctx context.Context, appID xid.ID, email, userName, eventType, eventTime, location, device string) error
SendSecurityAlert sends a security alert notification - HIGH priority (async with logging).
func (*AsyncAdapter) SendSuspiciousLogin ¶ added in v0.0.7
func (a *AsyncAdapter) SendSuspiciousLogin(ctx context.Context, appID xid.ID, recipientEmail, userName, reason, location, timestamp, ipAddress string) error
SendSuspiciousLogin sends a suspicious login alert - HIGH priority (async with logging).
func (*AsyncAdapter) SendUsernameChanged ¶ added in v0.0.7
func (a *AsyncAdapter) SendUsernameChanged(ctx context.Context, appID xid.ID, recipientEmail, userName, oldUsername, newUsername, timestamp string) error
SendUsernameChanged sends a username changed notification - NORMAL priority (async).
func (*AsyncAdapter) SendVerificationEmail ¶ added in v0.0.7
func (a *AsyncAdapter) SendVerificationEmail(ctx context.Context, appID xid.ID, email, userName, verificationURL, verificationCode string, expiryMinutes int) error
SendVerificationEmail sends a verification email - HIGH priority (async with logging).
func (*AsyncAdapter) SendWelcomeEmail ¶ added in v0.0.7
func (a *AsyncAdapter) SendWelcomeEmail(ctx context.Context, appID xid.ID, email, userName, loginURL string) error
SendWelcomeEmail sends a welcome email - NORMAL priority (async).
type AsyncConfig ¶ added in v0.0.7
type AsyncConfig struct {
// Enabled enables async processing for non-critical notifications
Enabled bool `json:"enabled" yaml:"enabled"`
// WorkerPoolSize is the number of workers for async processing
WorkerPoolSize int `json:"worker_pool_size" yaml:"worker_pool_size"`
// QueueSize is the buffer size for async queues
QueueSize int `json:"queue_size" yaml:"queue_size"`
// RetryEnabled enables retry for failed notifications
RetryEnabled bool `json:"retry_enabled" yaml:"retry_enabled"`
// MaxRetries is the maximum number of retry attempts
MaxRetries int `json:"max_retries" yaml:"max_retries"`
// RetryBackoff are the delays between retries (e.g., ["1m", "5m", "15m"])
RetryBackoff []string `json:"retry_backoff" yaml:"retry_backoff"`
// PersistFailures persists permanently failed notifications to DB
PersistFailures bool `json:"persist_failures" yaml:"persist_failures"`
}
AsyncConfig controls asynchronous notification processing.
type AuthAutoSendConfig ¶ added in v0.0.6
type AuthAutoSendConfig struct {
Welcome bool `json:"welcome" yaml:"welcome"`
VerificationEmail bool `json:"verification_email" yaml:"verification_email"`
MagicLink bool `json:"magic_link" yaml:"magic_link"`
EmailOTP bool `json:"email_otp" yaml:"email_otp"`
MFACode bool `json:"mfa_code" yaml:"mfa_code"`
PasswordReset bool `json:"password_reset" yaml:"password_reset"`
}
AuthAutoSendConfig controls authentication-related notifications.
type AuthAutoSendDTO ¶ added in v0.0.15
type AuthAutoSendDTO struct {
Welcome bool `json:"welcome"`
VerificationEmail bool `json:"verificationEmail"`
MagicLink bool `json:"magicLink"`
EmailOTP bool `json:"emailOtp"`
MFACode bool `json:"mfaCode"`
PasswordReset bool `json:"passwordReset"`
}
AuthAutoSendDTO represents authentication notification settings.
type AutoSendConfig ¶ added in v0.0.6
type AutoSendConfig struct {
Auth AuthAutoSendConfig `json:"auth" yaml:"auth"`
Organization OrganizationAutoSendConfig `json:"organization" yaml:"organization"`
Session SessionAutoSendConfig `json:"session" yaml:"session"`
Account AccountAutoSendConfig `json:"account" yaml:"account"`
}
AutoSendConfig controls automatic notification sending for lifecycle events.
type ChannelsResponse ¶
type Config ¶
type Config struct {
// AddDefaultTemplates automatically adds default templates on startup
AddDefaultTemplates bool `json:"add_default_templates" yaml:"add_default_templates"`
// DefaultLanguage is the default language for templates
DefaultLanguage string `json:"default_language" yaml:"default_language"`
// AllowAppOverrides allows apps to override default templates in SaaS mode
AllowAppOverrides bool `json:"allow_app_overrides" yaml:"allow_app_overrides"`
// AutoPopulateTemplates creates default templates for new apps
AutoPopulateTemplates bool `json:"auto_populate_templates" yaml:"auto_populate_templates"`
// AllowTemplateReset enables template reset functionality
AllowTemplateReset bool `json:"allow_template_reset" yaml:"allow_template_reset"`
// AutoSendWelcome automatically sends welcome email on user signup
// DEPRECATED: Use AutoSend.Auth.Welcome instead
AutoSendWelcome bool `json:"auto_send_welcome" yaml:"auto_send_welcome"`
// AutoSend configuration for automatic notification sending
AutoSend AutoSendConfig `json:"auto_send" yaml:"auto_send"`
// AppName is the default application name used in notifications
// If empty, will use the App name from the database
AppName string `json:"app_name" yaml:"app_name"`
// RetryAttempts is the number of retry attempts for failed notifications
RetryAttempts int `json:"retry_attempts" yaml:"retry_attempts"`
// RetryDelay is the delay between retry attempts
RetryDelay time.Duration `json:"retry_delay" yaml:"retry_delay"`
// CleanupAfter is the duration after which old notifications are deleted
CleanupAfter time.Duration `json:"cleanup_after" yaml:"cleanup_after"`
// RateLimits defines rate limits for notification sending
RateLimits map[string]RateLimit `json:"rate_limits" yaml:"rate_limits"`
// Providers configuration for email and SMS
Providers ProvidersConfig `json:"providers" yaml:"providers"`
// Async configuration for notification processing
Async AsyncConfig `json:"async" yaml:"async"`
}
Config holds the notification plugin configuration.
type CreateTemplateInput ¶ added in v0.0.15
type CreateTemplateInput struct {
TemplateKey string `json:"templateKey"`
Name string `json:"name"`
Type string `json:"type"`
Language string `json:"language,omitempty"`
Subject string `json:"subject,omitempty"`
Body string `json:"body"`
Variables []string `json:"variables,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
CreateTemplateInput is the input for creating a template.
type CreateTemplateResult ¶ added in v0.0.15
type CreateTemplateResult struct {
Success bool `json:"success"`
Template TemplateDTO `json:"template"`
Message string `json:"message,omitempty"`
}
CreateTemplateResult is the output for creating a template.
type DailyAnalyticsDTO ¶ added in v0.0.15
type DailyAnalyticsDTO struct {
Date string `json:"date"`
TotalSent int64 `json:"totalSent"`
TotalDelivered int64 `json:"totalDelivered"`
TotalOpened int64 `json:"totalOpened"`
TotalClicked int64 `json:"totalClicked"`
DeliveryRate float64 `json:"deliveryRate"`
OpenRate float64 `json:"openRate"`
}
DailyAnalyticsDTO represents analytics for a specific day.
type DashboardExtension ¶
type DashboardExtension struct {
// contains filtered or unexported fields
}
DashboardExtension provides dashboard UI for notifications.
func NewDashboardExtension ¶
func NewDashboardExtension(plugin *Plugin) *DashboardExtension
NewDashboardExtension creates a new dashboard extension.
func (*DashboardExtension) BridgeFunctions ¶ added in v0.0.15
func (e *DashboardExtension) BridgeFunctions() []ui.BridgeFunction
BridgeFunctions returns bridge functions for the notification plugin.
func (*DashboardExtension) DashboardWidgets ¶
func (e *DashboardExtension) DashboardWidgets() []ui.DashboardWidget
DashboardWidgets returns the notification stats widget.
func (*DashboardExtension) ExtensionID ¶
func (e *DashboardExtension) ExtensionID() string
ExtensionID returns the extension ID.
func (*DashboardExtension) NavigationItems ¶
func (e *DashboardExtension) NavigationItems() []ui.NavigationItem
NavigationItems returns the main "Notifications" navigation item.
func (*DashboardExtension) RenderDashboardWidget ¶
RenderDashboardWidget renders the notification stats widget for the main dashboard.
func (*DashboardExtension) Routes ¶
func (e *DashboardExtension) Routes() []ui.Route
Routes returns routes for the notification plugin.
func (*DashboardExtension) ServeAnalytics ¶ added in v0.0.15
func (e *DashboardExtension) ServeAnalytics(ctx *router.PageContext) (g.Node, error)
ServeAnalytics renders the analytics page.
func (*DashboardExtension) ServeEmailBuilder ¶ added in v0.0.3
func (e *DashboardExtension) ServeEmailBuilder(ctx *router.PageContext) (g.Node, error)
ServeEmailBuilder renders the email builder for new templates.
func (*DashboardExtension) ServeEmailBuilderWithTemplate ¶ added in v0.0.3
func (e *DashboardExtension) ServeEmailBuilderWithTemplate(ctx *router.PageContext) (g.Node, error)
ServeEmailBuilderWithTemplate renders the email builder with an existing template.
func (*DashboardExtension) ServeHistoryList ¶ added in v0.0.15
func (e *DashboardExtension) ServeHistoryList(ctx *router.PageContext) (g.Node, error)
ServeHistoryList renders the notification history list page.
func (*DashboardExtension) ServeOverview ¶ added in v0.0.15
func (e *DashboardExtension) ServeOverview(ctx *router.PageContext) (g.Node, error)
ServeOverview renders the notifications overview page.
func (*DashboardExtension) ServeProviders ¶ added in v0.0.15
func (e *DashboardExtension) ServeProviders(ctx *router.PageContext) (g.Node, error)
ServeProviders renders the providers settings page.
func (*DashboardExtension) ServeSettings ¶ added in v0.0.15
func (e *DashboardExtension) ServeSettings(ctx *router.PageContext) (g.Node, error)
ServeSettings renders the notification settings page.
func (*DashboardExtension) ServeTemplatesList ¶
func (e *DashboardExtension) ServeTemplatesList(ctx *router.PageContext) (g.Node, error)
ServeTemplatesList renders the templates list page.
func (*DashboardExtension) SettingsPages ¶
func (e *DashboardExtension) SettingsPages() []ui.SettingsPage
SettingsPages returns settings pages for the notification plugin.
func (*DashboardExtension) SettingsSections ¶
func (e *DashboardExtension) SettingsSections() []ui.SettingsSection
SettingsSections returns empty settings sections for now.
type DeclareABTestWinnerRequest ¶ added in v0.0.7
type DeclareABTestWinnerRequest struct {
TemplateID string `path:"templateId" validate:"required"`
}
type DeleteProviderRequest ¶ added in v0.0.7
type DeleteProviderRequest struct {
ID string `path:"id" validate:"required"`
}
type DeleteTemplateInput ¶ added in v0.0.15
type DeleteTemplateInput struct {
TemplateID string `json:"templateId"`
}
DeleteTemplateInput is the input for deleting a template.
type DeleteTemplateRequest ¶ added in v0.0.7
type DeleteTemplateRequest struct {
ID string `path:"id" validate:"required"`
}
type DeleteTemplateResult ¶ added in v0.0.15
type DeleteTemplateResult struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
}
DeleteTemplateResult is the output for deleting a template.
type EmailProviderConfig ¶
type EmailProviderConfig struct {
Provider string `json:"provider" yaml:"provider"` // smtp, sendgrid, ses, etc.
From string `json:"from" yaml:"from"`
FromName string `json:"from_name" yaml:"from_name"`
ReplyTo string `json:"reply_to" yaml:"reply_to"`
Config map[string]any `json:"config" yaml:"config"`
}
EmailProviderConfig holds email provider configuration.
type EmailProviderDTO ¶ added in v0.0.15
type EmailProviderDTO struct {
Type string `json:"type"` // "smtp", "sendgrid", "postmark", "mailersend", "resend"
Enabled bool `json:"enabled"`
Config map[string]any `json:"config,omitempty"`
FromName string `json:"fromName"`
FromEmail string `json:"fromEmail"`
}
EmailProviderDTO represents email provider configuration.
type ErrorResponse ¶
type ErrorResponse = responses.ErrorResponse
ErrorResponse types - use shared responses from core.
type GetABTestResultsRequest ¶ added in v0.0.7
type GetABTestResultsRequest struct {
TemplateID string `path:"templateId" validate:"required"`
}
GetABTestResultsRequest Test DTOs.
type GetAnalyticsInput ¶ added in v0.0.15
type GetAnalyticsInput struct {
Days *int `json:"days,omitempty"`
StartDate *string `json:"startDate,omitempty"`
EndDate *string `json:"endDate,omitempty"`
TemplateID *string `json:"templateId,omitempty"`
}
GetAnalyticsInput is the input for getting analytics data.
type GetAnalyticsResult ¶ added in v0.0.15
type GetAnalyticsResult struct {
Analytics AnalyticsDTO `json:"analytics"`
}
GetAnalyticsResult is the output for getting analytics data.
type GetNotificationDetailInput ¶ added in v0.0.15
type GetNotificationDetailInput struct {
NotificationID string `json:"notificationId"`
}
GetNotificationDetailInput is the input for getting a single notification.
type GetNotificationDetailResult ¶ added in v0.0.15
type GetNotificationDetailResult struct {
Notification NotificationHistoryDTO `json:"notification"`
}
GetNotificationDetailResult is the output for getting a single notification.
type GetNotificationRequest ¶ added in v0.0.7
type GetNotificationRequest struct {
ID string `path:"id" validate:"required"`
}
GetNotificationRequest DTOs.
type GetOverviewStatsInput ¶ added in v0.0.15
type GetOverviewStatsInput struct {
Days *int `json:"days,omitempty"` // Number of days to fetch stats for
StartDate *string `json:"startDate,omitempty"` // ISO date
EndDate *string `json:"endDate,omitempty"` // ISO date
}
GetOverviewStatsInput is the input for getting overview statistics.
type GetOverviewStatsResult ¶ added in v0.0.15
type GetOverviewStatsResult struct {
Stats OverviewStatsDTO `json:"stats"`
}
GetOverviewStatsResult is the output for getting overview statistics.
type GetProviderRequest ¶ added in v0.0.7
type GetProviderRequest struct {
ID string `path:"id" validate:"required"`
}
GetProviderRequest DTOs.
type GetProvidersInput ¶ added in v0.0.15
type GetProvidersInput struct {
}
GetProvidersInput is the input for getting providers configuration.
type GetProvidersResult ¶ added in v0.0.15
type GetProvidersResult struct {
Providers ProvidersConfigDTO `json:"providers"`
}
GetProvidersResult is the output for getting providers configuration.
type GetSettingsInput ¶ added in v0.0.15
type GetSettingsInput struct {
}
GetSettingsInput is the input for bridgeGetSettings.
type GetSettingsResult ¶ added in v0.0.15
type GetSettingsResult struct {
Settings NotificationSettingsDTO `json:"settings"`
}
GetSettingsResult is the output for bridgeGetSettings.
type GetTemplateAnalyticsRequest ¶ added in v0.0.7
type GetTemplateAnalyticsRequest struct {
TemplateID string `path:"templateId" validate:"required"`
}
GetTemplateAnalyticsRequest DTOs.
type GetTemplateInput ¶ added in v0.0.15
type GetTemplateInput struct {
TemplateID string `json:"templateId"`
}
GetTemplateInput is the input for getting a single template.
type GetTemplateRequest ¶ added in v0.0.7
type GetTemplateRequest struct {
ID string `path:"id" validate:"required"`
}
GetTemplateRequest DTOs.
type GetTemplateResult ¶ added in v0.0.15
type GetTemplateResult struct {
Template TemplateDTO `json:"template"`
}
GetTemplateResult is the output for getting a single template.
type GetTemplateVersionRequest ¶ added in v0.0.7
type GetTemplateVersionRequest struct {
TemplateID string `path:"templateId" validate:"required"`
VersionID string `path:"versionId" validate:"required"`
}
GetTemplateVersionRequest Version DTOs.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles notification HTTP requests.
func NewHandler ¶
func NewHandler(service *notification.Service, templateSvc *TemplateService, config Config) *Handler
NewHandler creates a new notification handler.
func (*Handler) CreateABTestVariant ¶
CreateABTestVariant creates a new A/B test variant.
func (*Handler) CreateProvider ¶
CreateProvider creates a new notification provider.
func (*Handler) CreateTemplate ¶
CreateTemplate creates a new notification template.
func (*Handler) CreateTemplateVersion ¶
CreateTemplateVersion creates a new version for a template.
func (*Handler) DeclareABTestWinner ¶
DeclareABTestWinner declares a winner for an A/B test.
func (*Handler) DeleteProvider ¶
DeleteProvider deletes a provider.
func (*Handler) DeleteTemplate ¶
DeleteTemplate deletes a template.
func (*Handler) GetABTestResults ¶
GetABTestResults retrieves A/B test results for a test group.
func (*Handler) GetAppAnalytics ¶
GetAppAnalytics retrieves analytics for an app.
func (*Handler) GetNotification ¶
GetNotification retrieves a notification by ID.
func (*Handler) GetOrgAnalytics ¶
GetOrgAnalytics retrieves analytics for an organization.
func (*Handler) GetProvider ¶
GetProvider retrieves a provider by ID.
func (*Handler) GetTemplate ¶
GetTemplate retrieves a template by ID.
func (*Handler) GetTemplateAnalytics ¶
GetTemplateAnalytics retrieves analytics for a template.
func (*Handler) GetTemplateDefaults ¶
GetTemplateDefaults returns default template metadata.
func (*Handler) GetTemplateVersion ¶
GetTemplateVersion retrieves a specific template version.
func (*Handler) HandleWebhook ¶
HandleWebhook handles provider webhook callbacks.
func (*Handler) ListNotifications ¶
ListNotifications lists all notifications with pagination.
func (*Handler) ListProviders ¶
ListProviders lists all providers for an app/org.
func (*Handler) ListTemplateVersions ¶
ListTemplateVersions lists all versions for a template.
func (*Handler) ListTemplates ¶
ListTemplates lists all templates with pagination.
func (*Handler) PreviewTemplate ¶
PreviewTemplate renders a template with provided variables.
func (*Handler) RenderTemplate ¶
RenderTemplate renders a template string with variables (no template ID required).
func (*Handler) ResendNotification ¶
ResendNotification resends a notification.
func (*Handler) ResetAllTemplates ¶
ResetAllTemplates resets all templates for an app to defaults.
func (*Handler) ResetTemplate ¶
ResetTemplate resets a template to default values.
func (*Handler) RestoreTemplateVersion ¶
RestoreTemplateVersion restores a template to a previous version.
func (*Handler) SendNotification ¶
SendNotification sends a notification.
func (*Handler) TrackNotificationEvent ¶
TrackNotificationEvent tracks an analytics event.
func (*Handler) UpdateProvider ¶
UpdateProvider updates a provider's configuration.
type ListNotificationsHistoryInput ¶ added in v0.0.15
type ListNotificationsHistoryInput struct {
Page int `json:"page,omitempty"`
Limit int `json:"limit,omitempty"`
Type *string `json:"type,omitempty"` // email, sms, push
Status *string `json:"status,omitempty"` // pending, sent, failed, delivered, bounced
Recipient *string `json:"recipient,omitempty"` // Filter by recipient
}
ListNotificationsHistoryInput is the input for listing notification history.
type ListNotificationsHistoryResult ¶ added in v0.0.15
type ListNotificationsHistoryResult struct {
Notifications []NotificationHistoryDTO `json:"notifications"`
Pagination PaginationDTO `json:"pagination"`
}
ListNotificationsHistoryResult is the output for listing notification history.
type ListTemplatesInput ¶ added in v0.0.15
type ListTemplatesInput struct {
Page int `json:"page,omitempty"`
Limit int `json:"limit,omitempty"`
Type *string `json:"type,omitempty"`
Language *string `json:"language,omitempty"`
Active *bool `json:"active,omitempty"`
}
ListTemplatesInput is the input for listing templates.
type ListTemplatesResult ¶ added in v0.0.15
type ListTemplatesResult struct {
Templates []TemplateDTO `json:"templates"`
Pagination PaginationDTO `json:"pagination"`
}
ListTemplatesResult is the output for listing templates.
type MailerSendConfig ¶
type MailerSendConfig = providers.MailerSendConfig
Re-export provider config types.
type MessageResponse ¶
type MessageResponse = responses.MessageResponse
type NotificationErrorResponse ¶
type NotificationErrorResponse struct {
Error string `example:"Error message" json:"error"`
}
NotificationErrorResponse types for notification routes.
type NotificationHistoryDTO ¶ added in v0.0.15
type NotificationHistoryDTO struct {
ID string `json:"id"`
AppID string `json:"appId"`
TemplateID *string `json:"templateId,omitempty"`
Type string `json:"type"`
Recipient string `json:"recipient"`
Subject string `json:"subject,omitempty"`
Body string `json:"body"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
ProviderID string `json:"providerId,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
SentAt *string `json:"sentAt,omitempty"` // ISO 8601
DeliveredAt *string `json:"deliveredAt,omitempty"` // ISO 8601
CreatedAt string `json:"createdAt"` // ISO 8601
UpdatedAt string `json:"updatedAt"` // ISO 8601
}
NotificationHistoryDTO represents a notification record in the history.
type NotificationResponse ¶
type NotificationResponse struct {
Notification any `json:"notification"`
}
type NotificationSettingsDTO ¶ added in v0.0.15
type NotificationSettingsDTO struct {
AppName string `json:"appName"`
Auth AuthAutoSendDTO `json:"auth"`
Organization OrganizationAutoSendDTO `json:"organization"`
Session SessionAutoSendDTO `json:"session"`
Account AccountAutoSendDTO `json:"account"`
}
NotificationSettingsDTO represents notification plugin settings.
type NotificationStatusResponse ¶
type NotificationStatusResponse struct {
Status string `example:"success" json:"status"`
}
type NotificationTemplateResponse ¶
type NotificationTemplateResponse struct {
Template any `json:"template"`
}
type NotificationWebhookResponse ¶
type NotificationWebhookResponse struct {
Status string `example:"processed" json:"status"`
}
type NotificationsResponse ¶
type OrganizationAutoSendConfig ¶ added in v0.0.6
type OrganizationAutoSendConfig struct {
Invite bool `json:"invite" yaml:"invite"`
MemberAdded bool `json:"member_added" yaml:"member_added"`
MemberRemoved bool `json:"member_removed" yaml:"member_removed"`
RoleChanged bool `json:"role_changed" yaml:"role_changed"`
Transfer bool `json:"transfer" yaml:"transfer"`
Deleted bool `json:"deleted" yaml:"deleted"`
MemberLeft bool `json:"member_left" yaml:"member_left"`
}
OrganizationAutoSendConfig controls organization-related notifications.
type OrganizationAutoSendDTO ¶ added in v0.0.15
type OrganizationAutoSendDTO struct {
Invite bool `json:"invite"`
MemberAdded bool `json:"memberAdded"`
MemberRemoved bool `json:"memberRemoved"`
RoleChanged bool `json:"roleChanged"`
Transfer bool `json:"transfer"`
Deleted bool `json:"deleted"`
MemberLeft bool `json:"memberLeft"`
}
OrganizationAutoSendDTO represents organization notification settings.
type OverviewStatsDTO ¶ added in v0.0.15
type OverviewStatsDTO struct {
TotalSent int64 `json:"totalSent"`
TotalDelivered int64 `json:"totalDelivered"`
TotalOpened int64 `json:"totalOpened"`
TotalClicked int64 `json:"totalClicked"`
TotalBounced int64 `json:"totalBounced"`
TotalFailed int64 `json:"totalFailed"`
DeliveryRate float64 `json:"deliveryRate"`
OpenRate float64 `json:"openRate"`
ClickRate float64 `json:"clickRate"`
BounceRate float64 `json:"bounceRate"`
}
OverviewStatsDTO represents overview statistics.
type PaginationDTO ¶ added in v0.0.15
type PaginationDTO struct {
CurrentPage int `json:"currentPage"`
TotalPages int `json:"totalPages"`
TotalCount int64 `json:"totalCount"`
PageSize int `json:"pageSize"`
HasNext bool `json:"hasNext"`
HasPrev bool `json:"hasPrev"`
}
PaginationDTO represents pagination metadata.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin implements the notification template management plugin.
func NewPlugin ¶
func NewPlugin(opts ...PluginOption) *Plugin
NewPlugin creates a new notification plugin instance with optional configuration.
func (*Plugin) DashboardExtension ¶
func (p *Plugin) DashboardExtension() ui.DashboardExtension
DashboardExtension returns the dashboard extension interface implementation.
func (*Plugin) GetService ¶
func (p *Plugin) GetService() *notification.Service
GetService returns the notification service for use by other plugins.
func (*Plugin) GetTemplateService ¶
func (p *Plugin) GetTemplateService() *TemplateService
GetTemplateService returns the template service for use by other plugins.
func (*Plugin) RegisterHooks ¶
func (p *Plugin) RegisterHooks(hookRegistry *hooks.HookRegistry) error
RegisterHooks registers plugin hooks.
func (*Plugin) RegisterRoutes ¶
RegisterRoutes registers HTTP routes for the plugin.
func (*Plugin) RegisterServiceDecorators ¶
func (p *Plugin) RegisterServiceDecorators(services *registry.ServiceRegistry) error
RegisterServiceDecorators registers the notification service and adapter.
type PluginOption ¶
type PluginOption func(*Plugin)
PluginOption is a functional option for configuring the notification plugin.
func WithAddDefaultTemplates ¶
func WithAddDefaultTemplates(add bool) PluginOption
WithAddDefaultTemplates sets whether to add default templates.
func WithAllowAppOverrides ¶
func WithAllowAppOverrides(allow bool) PluginOption
WithAllowAppOverrides sets whether to allow organization overrides.
func WithAutoSendWelcome ¶
func WithAutoSendWelcome(auto bool) PluginOption
WithAutoSendWelcome sets whether to auto-send welcome emails.
func WithDefaultConfig ¶
func WithDefaultConfig(cfg Config) PluginOption
WithDefaultConfig sets the default configuration for the plugin.
func WithDefaultLanguage ¶
func WithDefaultLanguage(lang string) PluginOption
WithDefaultLanguage sets the default language.
func WithEmailProvider ¶
func WithEmailProvider(provider, from, fromName string) PluginOption
WithEmailProvider sets the email provider configuration.
func WithRetryConfig ¶
func WithRetryConfig(attempts int, delay time.Duration) PluginOption
WithRetryConfig sets the retry configuration.
func WithSMSProvider ¶
func WithSMSProvider(provider, from string) PluginOption
WithSMSProvider sets the SMS provider configuration.
type PostmarkConfig ¶
type PostmarkConfig = providers.PostmarkConfig
Re-export provider config types.
type PreviewTemplateInput ¶ added in v0.0.15
type PreviewTemplateInput struct {
TemplateID string `json:"templateId"`
Variables map[string]any `json:"variables,omitempty"`
}
PreviewTemplateInput is the input for previewing a template.
type PreviewTemplateRequest ¶ added in v0.0.7
type PreviewTemplateRequest struct {
ID string `path:"id" validate:"required"`
}
type PreviewTemplateResult ¶ added in v0.0.15
type PreviewTemplateResult struct {
Subject string `json:"subject"`
Body string `json:"body"`
RenderedAt string `json:"renderedAt"`
}
PreviewTemplateResult is the output for previewing a template.
type ProvidersConfig ¶
type ProvidersConfig struct {
Email EmailProviderConfig `json:"email" yaml:"email"`
SMS *SMSProviderConfig `json:"sms,omitempty" yaml:"sms,omitempty"` // Optional SMS provider
}
ProvidersConfig holds provider configurations.
type ProvidersConfigDTO ¶ added in v0.0.15
type ProvidersConfigDTO struct {
EmailProvider EmailProviderDTO `json:"emailProvider"`
SMSProvider SMSProviderDTO `json:"smsProvider"`
}
ProvidersConfigDTO represents providers configuration.
type RateLimit ¶
type RateLimit struct {
MaxRequests int `json:"max_requests" yaml:"max_requests"`
Window time.Duration `json:"window" yaml:"window"`
}
RateLimit defines rate limiting configuration.
type RenderTemplateRequest ¶ added in v0.0.7
type RenderTemplateRequest struct {
ID string `path:"id" validate:"required"`
}
type ResendNotificationRequest ¶ added in v0.0.7
type ResendNotificationRequest struct {
ID string `path:"id" validate:"required"`
}
type ResetTemplateRequest ¶ added in v0.0.7
type ResetTemplateRequest struct {
ID string `path:"id" validate:"required"`
}
type RestoreTemplateVersionRequest ¶ added in v0.0.7
type SMSProviderConfig ¶
type SMSProviderConfig struct {
Provider string `json:"provider" yaml:"provider"` // twilio, vonage, aws-sns, etc.
From string `json:"from" yaml:"from"`
Config map[string]any `json:"config" yaml:"config"`
}
SMSProviderConfig holds SMS provider configuration.
type SMSProviderDTO ¶ added in v0.0.15
type SMSProviderDTO struct {
Type string `json:"type"` // "twilio", "vonage", "aws-sns"
Enabled bool `json:"enabled"`
Config map[string]any `json:"config,omitempty"`
}
SMSProviderDTO represents SMS provider configuration.
type SaveBuilderTemplateInput ¶ added in v0.0.15
type SaveBuilderTemplateInput struct {
TemplateID string `json:"templateId,omitempty"` // Empty for new template
Name string `json:"name"`
TemplateKey string `json:"templateKey"`
Subject string `json:"subject"`
BuilderJSON string `json:"builderJson"` // JSON of builder.Document
}
SaveBuilderTemplateInput is the input for saving a template from the visual builder.
type SaveBuilderTemplateResult ¶ added in v0.0.15
type SaveBuilderTemplateResult struct {
Success bool `json:"success"`
TemplateID string `json:"templateId,omitempty"`
Message string `json:"message"`
}
SaveBuilderTemplateResult is the output for saving a builder template.
type SendWithTemplateRequest ¶
type SendWithTemplateRequest struct {
AppID xid.ID `json:"appId"`
TemplateKey string `json:"templateKey"`
Type notification.NotificationType `json:"type"`
Recipient string `json:"recipient"`
Variables map[string]any `json:"variables"`
Language string `json:"language,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
SendWithTemplateRequest represents a request to send a notification using a template.
type SessionAutoSendConfig ¶ added in v0.0.6
type SessionAutoSendConfig struct {
NewDevice bool `json:"new_device" yaml:"new_device"`
NewLocation bool `json:"new_location" yaml:"new_location"`
SuspiciousLogin bool `json:"suspicious_login" yaml:"suspicious_login"`
DeviceRemoved bool `json:"device_removed" yaml:"device_removed"`
AllRevoked bool `json:"all_revoked" yaml:"all_revoked"`
}
SessionAutoSendConfig controls session/device security notifications.
type SessionAutoSendDTO ¶ added in v0.0.15
type SessionAutoSendDTO struct {
NewDevice bool `json:"newDevice"`
NewLocation bool `json:"newLocation"`
SuspiciousLogin bool `json:"suspiciousLogin"`
DeviceRemoved bool `json:"deviceRemoved"`
AllRevoked bool `json:"allRevoked"`
}
SessionAutoSendDTO represents session/security notification settings.
type StatusResponse ¶
type StatusResponse = responses.StatusResponse
type SuccessResponse ¶
type SuccessResponse = responses.SuccessResponse
type TemplateAnalyticsDTO ¶ added in v0.0.15
type TemplateAnalyticsDTO struct {
TemplateID string `json:"templateId"`
TemplateName string `json:"templateName"`
TotalSent int64 `json:"totalSent"`
TotalDelivered int64 `json:"totalDelivered"`
TotalOpened int64 `json:"totalOpened"`
TotalClicked int64 `json:"totalClicked"`
DeliveryRate float64 `json:"deliveryRate"`
OpenRate float64 `json:"openRate"`
ClickRate float64 `json:"clickRate"`
}
TemplateAnalyticsDTO represents analytics for a specific template.
type TemplateDTO ¶ added in v0.0.15
type TemplateDTO struct {
ID string `json:"id"`
AppID string `json:"appId"`
TemplateKey string `json:"templateKey"`
Name string `json:"name"`
Type string `json:"type"`
Language string `json:"language"`
Subject string `json:"subject,omitempty"`
Body string `json:"body"`
Variables []string `json:"variables"`
Metadata map[string]any `json:"metadata,omitempty"`
Active bool `json:"active"`
IsDefault bool `json:"isDefault"`
IsModified bool `json:"isModified"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
TemplateDTO represents a notification template.
type TemplateDefault ¶
type TemplateDefault struct {
TemplateKey string
Type string
Subject string
BodyText string
BodyHTML string
Variables []string
Description string
}
TemplateDefault represents a default template.
func DefaultTemplates ¶
func DefaultTemplates() []TemplateDefault
DefaultTemplates returns the default notification templates.
type TemplateEngine ¶
type TemplateEngine struct {
// contains filtered or unexported fields
}
TemplateEngine provides template rendering functionality.
func NewTemplateEngine ¶
func NewTemplateEngine() *TemplateEngine
NewTemplateEngine creates a new template engine.
func (*TemplateEngine) ExtractVariables ¶
func (e *TemplateEngine) ExtractVariables(templateStr string) ([]string, error)
ExtractVariables extracts variable names from a template.
func (*TemplateEngine) ValidateTemplate ¶
func (e *TemplateEngine) ValidateTemplate(templateStr string) error
ValidateTemplate validates a template for syntax errors.
type TemplatePerformanceDTO ¶ added in v0.0.15
type TemplatePerformanceDTO struct {
TemplateID string `json:"templateId"`
TemplateName string `json:"templateName"`
TotalSent int64 `json:"totalSent"`
OpenRate float64 `json:"openRate"`
ClickRate float64 `json:"clickRate"`
}
TemplatePerformanceDTO represents template performance ranking.
type TemplateService ¶
type TemplateService struct {
// contains filtered or unexported fields
}
TemplateService provides template-aware notification functionality.
func NewTemplateService ¶
func NewTemplateService( notificationSvc *notification.Service, repo notification.Repository, config Config, ) *TemplateService
NewTemplateService creates a new template service.
func (*TemplateService) RenderTemplate ¶
func (s *TemplateService) RenderTemplate(ctx context.Context, templateID xid.ID, variables map[string]any) (subject, body string, err error)
RenderTemplate renders a template with variables without sending.
func (*TemplateService) SendDirect ¶
func (s *TemplateService) SendDirect(ctx context.Context, appID xid.ID, notifType notification.NotificationType, recipient, subject, body string, metadata map[string]any) (*notification.Notification, error)
SendDirect sends a notification without using a template.
func (*TemplateService) SendEmail ¶
func (s *TemplateService) SendEmail(ctx context.Context, appID xid.ID, templateKey, to string, variables map[string]any) error
SendEmail sends an email notification.
func (*TemplateService) SendSMS ¶
func (s *TemplateService) SendSMS(ctx context.Context, appID xid.ID, templateKey, to string, variables map[string]any) error
SendSMS sends an SMS notification.
func (*TemplateService) SendWithTemplate ¶
func (s *TemplateService) SendWithTemplate(ctx context.Context, req *SendWithTemplateRequest) (*notification.Notification, error)
SendWithTemplate sends a notification using a template.
type TemplatesResponse ¶
type TestProviderInput ¶ added in v0.0.15
type TestProviderInput struct {
ProviderType string `json:"providerType"` // "email" or "sms"
Recipient string `json:"recipient"`
}
TestProviderInput is the input for testing a provider.
type TestProviderResult ¶ added in v0.0.15
TestProviderResult is the output for testing a provider.
type TestSendTemplateInput ¶ added in v0.0.15
type TestSendTemplateInput struct {
TemplateID string `json:"templateId"`
Recipient string `json:"recipient"`
Variables map[string]any `json:"variables,omitempty"`
}
TestSendTemplateInput is the input for test sending a template.
type TestSendTemplateResult ¶ added in v0.0.15
type TestSendTemplateResult struct {
Success bool `json:"success"`
Message string `json:"message"`
}
TestSendTemplateResult is the output for test sending a template.
type UpdateProviderRequest ¶ added in v0.0.7
type UpdateProviderRequest struct {
ID string `path:"id" validate:"required"`
}
type UpdateProvidersInput ¶ added in v0.0.15
type UpdateProvidersInput struct {
EmailProvider *EmailProviderDTO `json:"emailProvider,omitempty"`
SMSProvider *SMSProviderDTO `json:"smsProvider,omitempty"`
}
UpdateProvidersInput is the input for updating providers configuration.
type UpdateProvidersResult ¶ added in v0.0.15
type UpdateProvidersResult struct {
Success bool `json:"success"`
Providers ProvidersConfigDTO `json:"providers"`
Message string `json:"message,omitempty"`
}
UpdateProvidersResult is the output for updating providers configuration.
type UpdateSettingsInput ¶ added in v0.0.15
type UpdateSettingsInput struct {
AppName string `json:"appName,omitempty"`
Auth *AuthAutoSendDTO `json:"auth,omitempty"`
Organization *OrganizationAutoSendDTO `json:"organization,omitempty"`
Session *SessionAutoSendDTO `json:"session,omitempty"`
Account *AccountAutoSendDTO `json:"account,omitempty"`
}
UpdateSettingsInput is the input for bridgeUpdateSettings.
type UpdateSettingsResult ¶ added in v0.0.15
type UpdateSettingsResult struct {
Success bool `json:"success"`
Settings NotificationSettingsDTO `json:"settings"`
Message string `json:"message,omitempty"`
}
UpdateSettingsResult is the output for bridgeUpdateSettings.
type UpdateTemplateInput ¶ added in v0.0.15
type UpdateTemplateInput struct {
TemplateID string `json:"templateId"`
Name *string `json:"name,omitempty"`
Subject *string `json:"subject,omitempty"`
Body *string `json:"body,omitempty"`
Variables []string `json:"variables,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Active *bool `json:"active,omitempty"`
}
UpdateTemplateInput is the input for updating a template.
type UpdateTemplateRequest ¶ added in v0.0.7
type UpdateTemplateRequest struct {
ID string `path:"id" validate:"required"`
}
type UpdateTemplateResult ¶ added in v0.0.15
type UpdateTemplateResult struct {
Success bool `json:"success"`
Template TemplateDTO `json:"template"`
Message string `json:"message,omitempty"`
}
UpdateTemplateResult is the output for updating a template.