Refactor Notification Email Structure in Customer and User Services

- Updated the email notification logic in the customer and user service layers to utilize the new notification Model struct, enhancing the clarity and consistency of notification requests.
- Modified the email content to include structured fields such as Title, Message, Type, Priority, and UserID, improving the overall notification management.
- Ensured that all relevant service methods (Register, UpdateStatus, RequestResetPassword, ResetPassword) are updated to reflect these changes, promoting a unified approach to notification handling.
This commit is contained in:
n.nakhostin
2025-09-20 15:35:53 +03:30
parent 0857314906
commit d2f7c6a1e5
2 changed files with 56 additions and 7 deletions
+24 -3
View File
@@ -117,7 +117,14 @@ func (s *userService) Register(ctx context.Context, form *CreateUserForm) (*User
"role": user.Role,
})
go s.notification.SendEmail(ctx, form.Email, fmt.Sprintf("Welcome to Tender Management\nUsername: %s\nPassword: %s", form.Username, form.Password), user.ID.Hex())
go 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),
Type: "info",
Priority: "important",
UserID: user.ID.Hex(),
})
return user.ToResponse(), nil
}
@@ -221,7 +228,14 @@ func (s *userService) UpdateStatus(ctx context.Context, id string, form *UpdateU
"status": form.Status,
})
go s.notification.SendEmail(ctx, user.Email, fmt.Sprintf("Your account has been %s", strings.ToUpper(form.Status)), user.ID.Hex())
go 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)),
Type: "warning",
Priority: "important",
UserID: user.ID.Hex(),
})
return nil
}
@@ -456,7 +470,14 @@ func (s *userService) ChangePassword(ctx context.Context, userID string, form *C
"user_id": userID,
})
go s.notification.SendEmail(ctx, user.Email, "Your password has been reset successfully", user.ID.Hex())
go s.notification.SendEmail(ctx, notification.Model{
Recipient: user.Email,
Title: "Password Reset Success",
Message: "Your password has been reset successfully",
Type: "info",
Priority: "important",
UserID: user.ID.Hex(),
})
return nil
}