Skip to content

Commit

Permalink
refact: email: rename methods (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
crlssn authored Dec 23, 2024
1 parent 1e32071 commit 2eb05ad
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions server/email/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
)

type Email interface {
SendVerificationEmail(ctx context.Context, req SendVerificationEmail) error
SendPasswordResetEmail(ctx context.Context, req SendPasswordResetEmail) error
SendVerification(ctx context.Context, req SendVerification) error
SendPasswordReset(ctx context.Context, req SendPasswordReset) error
}

type email struct {
Expand Down Expand Up @@ -51,13 +51,13 @@ func MustNew(c *c.Config) Email {
return e
}

type SendVerificationEmail struct {
type SendVerification struct {
Name string
Email string
Token string
}

func (e *email) SendVerificationEmail(ctx context.Context, req SendVerificationEmail) error {
func (e *email) SendVerification(ctx context.Context, req SendVerification) error {
sender := "[email protected]"
subject := "[GetStronger] Verify your email"
body := fmt.Sprintf(`Hi %s,
Expand Down Expand Up @@ -89,13 +89,13 @@ Please verify your email address by clicking on the link below.
return nil
}

type SendPasswordResetEmail struct {
type SendPasswordReset struct {
Name string
Email string
Token string
}

func (e *email) SendPasswordResetEmail(ctx context.Context, req SendPasswordResetEmail) error {
func (e *email) SendPasswordReset(ctx context.Context, req SendPasswordReset) error {
sender := "[email protected]"
subject := "[GetStronger] Reset your password"
body := fmt.Sprintf(`Hi %s,
Expand Down
2 changes: 1 addition & 1 deletion server/email/email_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestSendEmail(t *testing.T) {
t.Parallel()
email := MustNew(&config.Config{})

err := email.SendVerificationEmail(context.Background(), SendVerificationEmail{
err := email.SendVerification(context.Background(), SendVerification{
Name: "John Doe",
Email: os.Getenv("GET_STRONGER_EMAIL_ADDRESS"),
Token: "1234",
Expand Down
4 changes: 2 additions & 2 deletions server/email/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ func NewNoop() Email {
return &noop{}
}

func (n *noop) SendVerificationEmail(_ context.Context, _ SendVerificationEmail) error {
func (n *noop) SendVerification(_ context.Context, _ SendVerification) error {
return nil
}

func (n *noop) SendPasswordResetEmail(_ context.Context, _ SendPasswordResetEmail) error {
func (n *noop) SendPasswordReset(_ context.Context, _ SendPasswordReset) error {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions server/rpc/handlers/v1/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (h *authHandler) Signup(ctx context.Context, req *connect.Request[apiv1.Sig
return fmt.Errorf("create user: %w", err)
}

if err = h.email.SendVerificationEmail(ctx, email.SendVerificationEmail{
if err = h.email.SendVerification(ctx, email.SendVerification{
Name: user.FirstName,
Email: auth.Email,
Token: auth.EmailToken,
Expand Down Expand Up @@ -276,7 +276,7 @@ func (h *authHandler) ResetPassword(ctx context.Context, req *connect.Request[ap
return nil, connect.NewError(connect.CodeInternal, nil)
}

if err = h.email.SendPasswordResetEmail(ctx, email.SendPasswordResetEmail{
if err = h.email.SendPasswordReset(ctx, email.SendPasswordReset{
Name: auth.R.User.FirstName,
Email: auth.Email,
Token: token,
Expand Down

0 comments on commit 2eb05ad

Please sign in to comment.