add: contactController,tests & refactored tests
This commit is contained in:
@@ -13,13 +13,12 @@ import (
|
||||
)
|
||||
|
||||
type EmailService struct {
|
||||
dialer *gomail.Dialer
|
||||
adminEmail string
|
||||
dialer *gomail.Dialer
|
||||
}
|
||||
|
||||
func NewEmailService(host string, port int, username, password, adminEmail string) *EmailService {
|
||||
func NewEmailService(host string, port int, username string, password string) *EmailService {
|
||||
dialer := gomail.NewDialer(host, port, username, password)
|
||||
return &EmailService{dialer: dialer, adminEmail: adminEmail}
|
||||
return &EmailService{dialer: dialer}
|
||||
}
|
||||
|
||||
func (s *EmailService) SendEmail(to string, subject string, body string) error {
|
||||
@@ -87,10 +86,10 @@ func (s *EmailService) SendWelcomeEmail(user *models.User) error {
|
||||
Company string
|
||||
FirstName string
|
||||
MembershipModel string
|
||||
BASEURL string
|
||||
MembershipID int64
|
||||
MembershipFee float32
|
||||
RentalFee float32
|
||||
BASEURL string
|
||||
}{
|
||||
Company: user.Company,
|
||||
FirstName: user.FirstName,
|
||||
@@ -110,24 +109,24 @@ func (s *EmailService) SendWelcomeEmail(user *models.User) error {
|
||||
return s.SendEmail(user.Email, subject, body)
|
||||
}
|
||||
|
||||
func (s *EmailService) NotifyAdminOfNewUser(user *models.User) error {
|
||||
func (s *EmailService) SendRegistrationNotification(user *models.User) error {
|
||||
// Prepare data to be injected into the template
|
||||
data := struct {
|
||||
City string
|
||||
Email string
|
||||
FirstName string
|
||||
DateOfBirth string
|
||||
LastName string
|
||||
MembershipModel string
|
||||
Address string
|
||||
IBAN string
|
||||
FirstName string
|
||||
Email string
|
||||
Phone string
|
||||
DateOfBirth string
|
||||
City string
|
||||
Company string
|
||||
ZipCode string
|
||||
BASEURL string
|
||||
MembershipID int64
|
||||
RentalFee float32
|
||||
MembershipFee float32
|
||||
BASEURL string
|
||||
}{
|
||||
Company: user.Company,
|
||||
FirstName: user.FirstName,
|
||||
@@ -152,7 +151,7 @@ func (s *EmailService) NotifyAdminOfNewUser(user *models.User) error {
|
||||
logger.Error.Print("Couldn't send admin notification mail")
|
||||
return err
|
||||
}
|
||||
return s.SendEmail(config.SMTP.AdminEmail, subject, body)
|
||||
return s.SendEmail(config.Recipients.UserRegistration, subject, body)
|
||||
}
|
||||
|
||||
func (s *EmailService) RelayContactFormMessage(sender string, name string, message string) error {
|
||||
@@ -171,5 +170,5 @@ func (s *EmailService) RelayContactFormMessage(sender string, name string, messa
|
||||
logger.Error.Print("Couldn't send contact form message mail")
|
||||
return err
|
||||
}
|
||||
return s.SendEmail(config.SMTP.AdminEmail, subject, body)
|
||||
return s.SendEmail(config.Recipients.ContactForm, subject, body)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user