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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user