Documentation ¶
Index ¶
- Variables
- func SetWebhookClient(client WebhookClient)
- type AttachedFile
- type EmailSender
- type EmailVerificationMailer
- type FakeDisconnectedMailer
- type FakeMailer
- type GetUserByLoginFunc
- type Mailer
- type Message
- type NotificationService
- func (ns *NotificationService) GetMailer() Mailer
- func (ns *NotificationService) Run(ctx context.Context) error
- func (ns *NotificationService) Send(ctx context.Context, msg *Message) (int, error)
- func (ns *NotificationService) SendEmailCommandHandler(ctx context.Context, cmd *SendEmailCommand) error
- func (ns *NotificationService) SendEmailCommandHandlerSync(ctx context.Context, cmd *SendEmailCommandSync) error
- func (ns *NotificationService) SendResetPasswordEmail(ctx context.Context, cmd *SendResetPasswordEmailCommand) error
- func (ns *NotificationService) SendVerificationEmail(ctx context.Context, cmd *SendVerifyEmailCommand) error
- func (ns *NotificationService) SendWebhookSync(ctx context.Context, cmd *SendWebhookSync) error
- func (ns *NotificationService) ValidateResetPasswordCode(ctx context.Context, query *ValidateResetPasswordCodeQuery, ...) (*user.User, error)
- type NotificationServiceMock
- func (ns *NotificationServiceMock) SendEmailCommandHandler(ctx context.Context, cmd *SendEmailCommand) error
- func (ns *NotificationServiceMock) SendEmailCommandHandlerSync(ctx context.Context, cmd *SendEmailCommandSync) error
- func (ns *NotificationServiceMock) SendResetPasswordEmail(ctx context.Context, cmd *SendResetPasswordEmailCommand) error
- func (ns *NotificationServiceMock) SendVerificationEmail(ctx context.Context, cmd *SendVerifyEmailCommand) error
- func (ns *NotificationServiceMock) SendWebhookSync(ctx context.Context, cmd *SendWebhookSync) error
- func (ns *NotificationServiceMock) ValidateResetPasswordCode(ctx context.Context, query *ValidateResetPasswordCodeQuery, ...) (*user.User, error)
- type PasswordResetMailer
- type SendEmailAttachFile
- type SendEmailCommand
- type SendEmailCommandSync
- type SendResetPasswordEmailCommand
- type SendVerifyEmailCommand
- type SendWebhookSync
- type Service
- type SmtpClient
- type TempUserStore
- type ValidateResetPasswordCodeQuery
- type Webhook
- type WebhookClient
- type WebhookSender
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidEmailCode = errors.New("invalid or expired email code")
View Source
var ErrSmtpNotEnabled = errors.New("SMTP not configured, check your grafana.ini config file's [smtp] section")
View Source
var NetClient = &netClient
NetClient is used to export original in test.
Functions ¶
func SetWebhookClient ¶
func SetWebhookClient(client WebhookClient)
SetWebhookClient is used to mock in test.
Types ¶
type AttachedFile ¶
AttachedFile struct represents email attached files.
type EmailSender ¶
type EmailSender interface { SendEmailCommandHandlerSync(ctx context.Context, cmd *SendEmailCommandSync) error SendEmailCommandHandler(ctx context.Context, cmd *SendEmailCommand) error }
type EmailVerificationMailer ¶
type EmailVerificationMailer interface {
SendVerificationEmail(ctx context.Context, cmd *SendVerifyEmailCommand) error
}
type FakeDisconnectedMailer ¶
type FakeDisconnectedMailer struct{}
func NewFakeDisconnectedMailer ¶
func NewFakeDisconnectedMailer() *FakeDisconnectedMailer
type FakeMailer ¶
type FakeMailer struct {
Sent []*Message
}
func NewFakeMailer ¶
func NewFakeMailer() *FakeMailer
type GetUserByLoginFunc ¶
type Message ¶
type Message struct { To []string SingleEmail bool From string Subject string Body map[string]string Info string ReplyTo []string EmbeddedFiles []string AttachedFiles []*AttachedFile }
Message is representation of the email message.
type NotificationService ¶
type NotificationService struct { Bus bus.Bus Cfg *setting.Cfg // contains filtered or unexported fields }
func ProvideService ¶
func ProvideService(bus bus.Bus, cfg *setting.Cfg, mailer Mailer, store TempUserStore) (*NotificationService, error)
func (*NotificationService) GetMailer ¶
func (ns *NotificationService) GetMailer() Mailer
func (*NotificationService) SendEmailCommandHandler ¶
func (ns *NotificationService) SendEmailCommandHandler(ctx context.Context, cmd *SendEmailCommand) error
func (*NotificationService) SendEmailCommandHandlerSync ¶
func (ns *NotificationService) SendEmailCommandHandlerSync(ctx context.Context, cmd *SendEmailCommandSync) error
func (*NotificationService) SendResetPasswordEmail ¶
func (ns *NotificationService) SendResetPasswordEmail(ctx context.Context, cmd *SendResetPasswordEmailCommand) error
func (*NotificationService) SendVerificationEmail ¶
func (ns *NotificationService) SendVerificationEmail(ctx context.Context, cmd *SendVerifyEmailCommand) error
func (*NotificationService) SendWebhookSync ¶
func (ns *NotificationService) SendWebhookSync(ctx context.Context, cmd *SendWebhookSync) error
func (*NotificationService) ValidateResetPasswordCode ¶
func (ns *NotificationService) ValidateResetPasswordCode(ctx context.Context, query *ValidateResetPasswordCodeQuery, userByLogin GetUserByLoginFunc) (*user.User, error)
type NotificationServiceMock ¶
type NotificationServiceMock struct { Webhook SendWebhookSync EmailSync SendEmailCommandSync Email SendEmailCommand EmailVerified bool EmailVerification SendVerifyEmailCommand ShouldError error WebhookHandler func(context.Context, *SendWebhookSync) error EmailHandlerSync func(context.Context, *SendEmailCommandSync) error EmailHandler func(context.Context, *SendEmailCommand) error }
func MockNotificationService ¶
func MockNotificationService() *NotificationServiceMock
func (*NotificationServiceMock) SendEmailCommandHandler ¶
func (ns *NotificationServiceMock) SendEmailCommandHandler(ctx context.Context, cmd *SendEmailCommand) error
func (*NotificationServiceMock) SendEmailCommandHandlerSync ¶
func (ns *NotificationServiceMock) SendEmailCommandHandlerSync(ctx context.Context, cmd *SendEmailCommandSync) error
func (*NotificationServiceMock) SendResetPasswordEmail ¶
func (ns *NotificationServiceMock) SendResetPasswordEmail(ctx context.Context, cmd *SendResetPasswordEmailCommand) error
func (*NotificationServiceMock) SendVerificationEmail ¶
func (ns *NotificationServiceMock) SendVerificationEmail(ctx context.Context, cmd *SendVerifyEmailCommand) error
func (*NotificationServiceMock) SendWebhookSync ¶
func (ns *NotificationServiceMock) SendWebhookSync(ctx context.Context, cmd *SendWebhookSync) error
func (*NotificationServiceMock) ValidateResetPasswordCode ¶
func (ns *NotificationServiceMock) ValidateResetPasswordCode(ctx context.Context, query *ValidateResetPasswordCodeQuery, userByLogin GetUserByLoginFunc) (*user.User, error)
type PasswordResetMailer ¶
type PasswordResetMailer interface { SendResetPasswordEmail(ctx context.Context, cmd *SendResetPasswordEmailCommand) error ValidateResetPasswordCode(ctx context.Context, query *ValidateResetPasswordCodeQuery, userByLogin GetUserByLoginFunc) (*user.User, error) }
type SendEmailAttachFile ¶
SendEmailAttachFile is a definition of the attached files without path
type SendEmailCommand ¶
type SendEmailCommand struct { To []string SingleEmail bool Template string Subject string Data map[string]any Info string ReplyTo []string EmbeddedFiles []string AttachedFiles []*SendEmailAttachFile }
SendEmailCommand is the command for sending emails
type SendEmailCommandSync ¶
type SendEmailCommandSync struct {
SendEmailCommand
}
SendEmailCommandSync is the command for sending emails synchronously
type SendVerifyEmailCommand ¶
type SendWebhookSync ¶
type Service ¶
type Service interface { WebhookSender EmailSender PasswordResetMailer EmailVerificationMailer }
type SmtpClient ¶
type SmtpClient struct {
// contains filtered or unexported fields
}
func NewSmtpClient ¶
func NewSmtpClient(cfg setting.SmtpSettings) (*SmtpClient, error)
type TempUserStore ¶
type TempUserStore interface {
UpdateTempUserWithEmailSent(ctx context.Context, cmd *tempuser.UpdateTempUserWithEmailSentCommand) error
}
type ValidateResetPasswordCodeQuery ¶
type ValidateResetPasswordCodeQuery struct {
Code string
}
type Webhook ¶
type Webhook struct { Url string User string Password string Body string HttpMethod string HttpHeader map[string]string ContentType string // Validation is a function that will validate the response body and statusCode of the webhook. Any returned error will cause the webhook request to be considered failed. // This can be useful when a webhook service communicates failures in creative ways, such as using the response body instead of the status code. Validation func(body []byte, statusCode int) error }
type WebhookClient ¶
WebhookClient exists to mock the client in tests.
type WebhookSender ¶
type WebhookSender interface {
SendWebhookSync(ctx context.Context, cmd *SendWebhookSync) error
}
Click to show internal directories.
Click to hide internal directories.