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:
n.nakhostin
2025-09-21 14:59:40 +03:30
parent 67b2058506
commit 29bca402a4
2 changed files with 7 additions and 7 deletions
+4 -4
View File
@@ -145,7 +145,7 @@ func (s *customerService) Register(ctx context.Context, form *CreateCustomerForm
"company_ids": Companies,
})
go s.notification.SendEmail(ctx, notification.Model{
s.notification.SendEmail(ctx, notification.Model{
Recipient: customer.Email,
Title: "Welcome to Opplens",
Message: fmt.Sprintf("Welcome to Opplens\nUsername: %s\nPassword: %s", customer.Username, form.Password),
@@ -412,7 +412,7 @@ func (s *customerService) UpdateStatus(ctx context.Context, id string, form *Upd
"status": form.Status,
})
go s.notification.SendEmail(ctx, notification.Model{
s.notification.SendEmail(ctx, notification.Model{
Recipient: customer.Email,
Title: "Account Status Updated",
Message: fmt.Sprintf("Your account has been %s", strings.ToUpper(form.Status)),
@@ -858,7 +858,7 @@ func (s *customerService) RequestResetPassword(ctx context.Context, form *Reques
}
// Send OTP via email
go s.notification.SendEmail(ctx, notification.Model{
s.notification.SendEmail(ctx, notification.Model{
Recipient: form.Email,
Title: "Password Reset",
Message: fmt.Sprintf("Your password reset code is: %s", otpCode),
@@ -1053,7 +1053,7 @@ func (s *customerService) ResetPassword(ctx context.Context, form *ResetPassword
"customer_id": customer.ID,
})
go s.notification.SendEmail(ctx, notification.Model{
s.notification.SendEmail(ctx, notification.Model{
Recipient: tokenData.Email,
Title: "Password Reset Success",
Message: "Your password has been reset successfully",