mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 16:13:02 +08:00
chore: avoid aliasing imports in services (#22499)
This commit is contained in:
@ -12,7 +12,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/events"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
m "github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/registry"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
@ -100,7 +100,7 @@ func (ns *NotificationService) Run(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
func (ns *NotificationService) SendWebhookSync(ctx context.Context, cmd *m.SendWebhookSync) error {
|
||||
func (ns *NotificationService) SendWebhookSync(ctx context.Context, cmd *models.SendWebhookSync) error {
|
||||
return ns.sendWebRequestSync(ctx, &Webhook{
|
||||
Url: cmd.Url,
|
||||
User: cmd.User,
|
||||
@ -117,8 +117,8 @@ func subjectTemplateFunc(obj map[string]interface{}, value string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (ns *NotificationService) sendEmailCommandHandlerSync(ctx context.Context, cmd *m.SendEmailCommandSync) error {
|
||||
message, err := ns.buildEmailMessage(&m.SendEmailCommand{
|
||||
func (ns *NotificationService) sendEmailCommandHandlerSync(ctx context.Context, cmd *models.SendEmailCommandSync) error {
|
||||
message, err := ns.buildEmailMessage(&models.SendEmailCommand{
|
||||
Data: cmd.Data,
|
||||
Info: cmd.Info,
|
||||
Template: cmd.Template,
|
||||
@ -136,7 +136,7 @@ func (ns *NotificationService) sendEmailCommandHandlerSync(ctx context.Context,
|
||||
return err
|
||||
}
|
||||
|
||||
func (ns *NotificationService) sendEmailCommandHandler(cmd *m.SendEmailCommand) error {
|
||||
func (ns *NotificationService) sendEmailCommandHandler(cmd *models.SendEmailCommand) error {
|
||||
message, err := ns.buildEmailMessage(cmd)
|
||||
|
||||
if err != nil {
|
||||
@ -147,12 +147,12 @@ func (ns *NotificationService) sendEmailCommandHandler(cmd *m.SendEmailCommand)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ns *NotificationService) sendResetPasswordEmail(cmd *m.SendResetPasswordEmailCommand) error {
|
||||
func (ns *NotificationService) sendResetPasswordEmail(cmd *models.SendResetPasswordEmailCommand) error {
|
||||
code, err := createUserEmailCode(cmd.User, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ns.sendEmailCommandHandler(&m.SendEmailCommand{
|
||||
return ns.sendEmailCommandHandler(&models.SendEmailCommand{
|
||||
To: []string{cmd.User.Email},
|
||||
Template: tmplResetPassword,
|
||||
Data: map[string]interface{}{
|
||||
@ -162,13 +162,13 @@ func (ns *NotificationService) sendResetPasswordEmail(cmd *m.SendResetPasswordEm
|
||||
})
|
||||
}
|
||||
|
||||
func (ns *NotificationService) validateResetPasswordCode(query *m.ValidateResetPasswordCodeQuery) error {
|
||||
func (ns *NotificationService) validateResetPasswordCode(query *models.ValidateResetPasswordCodeQuery) error {
|
||||
login := getLoginForEmailCode(query.Code)
|
||||
if login == "" {
|
||||
return m.ErrInvalidEmailCode
|
||||
return models.ErrInvalidEmailCode
|
||||
}
|
||||
|
||||
userQuery := m.GetUserByLoginQuery{LoginOrEmail: login}
|
||||
userQuery := models.GetUserByLoginQuery{LoginOrEmail: login}
|
||||
if err := bus.Dispatch(&userQuery); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -178,7 +178,7 @@ func (ns *NotificationService) validateResetPasswordCode(query *m.ValidateResetP
|
||||
return err
|
||||
}
|
||||
if !validEmailCode {
|
||||
return m.ErrInvalidEmailCode
|
||||
return models.ErrInvalidEmailCode
|
||||
}
|
||||
|
||||
query.Result = userQuery.Result
|
||||
@ -196,7 +196,7 @@ func (ns *NotificationService) signUpStartedHandler(evt *events.SignUpStarted) e
|
||||
return nil
|
||||
}
|
||||
|
||||
err := ns.sendEmailCommandHandler(&m.SendEmailCommand{
|
||||
err := ns.sendEmailCommandHandler(&models.SendEmailCommand{
|
||||
To: []string{evt.Email},
|
||||
Template: tmplSignUpStarted,
|
||||
Data: map[string]interface{}{
|
||||
@ -210,7 +210,7 @@ func (ns *NotificationService) signUpStartedHandler(evt *events.SignUpStarted) e
|
||||
return err
|
||||
}
|
||||
|
||||
emailSentCmd := m.UpdateTempUserWithEmailSentCommand{Code: evt.Code}
|
||||
emailSentCmd := models.UpdateTempUserWithEmailSentCommand{Code: evt.Code}
|
||||
return bus.Dispatch(&emailSentCmd)
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ func (ns *NotificationService) signUpCompletedHandler(evt *events.SignUpComplete
|
||||
return nil
|
||||
}
|
||||
|
||||
return ns.sendEmailCommandHandler(&m.SendEmailCommand{
|
||||
return ns.sendEmailCommandHandler(&models.SendEmailCommand{
|
||||
To: []string{evt.Email},
|
||||
Template: tmplWelcomeOnSignUp,
|
||||
Data: map[string]interface{}{
|
||||
|
Reference in New Issue
Block a user