Refactor Notification Sending Logic in Customer and User Services
- Updated the notification sending logic in the customer and user service layers to send emails synchronously instead of using goroutines, improving clarity and ensuring immediate feedback on notification processing. - Ensured that all relevant service methods (Register, UpdateStatus, RequestResetPassword, ResetPassword) are updated to reflect these changes, promoting consistency in notification handling across services.
This commit is contained in:
@@ -118,7 +118,7 @@ func (s *userService) Register(ctx context.Context, form *CreateUserForm) (*User
|
||||
"role": user.Role,
|
||||
})
|
||||
|
||||
go s.notification.SendEmail(ctx, notification.Model{
|
||||
s.notification.SendEmail(ctx, notification.Model{
|
||||
Recipient: form.Email,
|
||||
Title: "Welcome to Opplens",
|
||||
Message: fmt.Sprintf("Welcome to Opplens\nUsername: %s\nPassword: %s", form.Username, form.Password),
|
||||
@@ -229,7 +229,7 @@ func (s *userService) UpdateStatus(ctx context.Context, id string, form *UpdateU
|
||||
"status": form.Status,
|
||||
})
|
||||
|
||||
go s.notification.SendEmail(ctx, notification.Model{
|
||||
s.notification.SendEmail(ctx, notification.Model{
|
||||
Recipient: user.Email,
|
||||
Title: "Account Status Updated",
|
||||
Message: fmt.Sprintf("Your account has been %s", strings.ToUpper(form.Status)),
|
||||
@@ -488,7 +488,7 @@ func (s *userService) ChangePassword(ctx context.Context, userID string, form *C
|
||||
"user_id": userID,
|
||||
})
|
||||
|
||||
go s.notification.SendEmail(ctx, notification.Model{
|
||||
s.notification.SendEmail(ctx, notification.Model{
|
||||
Recipient: user.Email,
|
||||
Title: "Password Reset Success",
|
||||
Message: "Your password has been reset successfully",
|
||||
|
||||
Reference in New Issue
Block a user